473,811 Members | 2,540 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagram Reading - C#

1 New Member
On form load it preforms this action:

Expand|Select|Wrap|Line Numbers
  1. string IP = "*";
  2. int Port = *;
  3. IPEndPoint RemoteEndPoint = new IPEndPoint(System.Net.IPAddress.Parse(IP), Port);
  4. UdpClient Client = new UdpClient();
  5. byte[] sendDatagram = { 0xff, 0xff, 0xff, 0xff, 0x54, 0x53, 0x6f, 0x75, 0x72, 0x63, 
  6. 0x65, 0x20, 0x45, 0x6e, 0x67, 0x69, 0x6e, 0x65, 0x20, 0x51, 
  7. 0x75, 0x65, 0x72, 0x79, 0x0 };
  8. byte[] receiveDatagram;
  9. try
  10. {
  11.        Client.Send(sendDatagram, sendDatagram.Length, RemoteEndPoint);
  12.        receiveDatagram = Client.Receive(ref RemoteEndPoint);
  13.        Client.Close();
  14.        label1.Text = Encoding.ASCII.GetString(receiveDatagram, 6, 117).ToString();
  15.        labelResult.Text = receiveDatagram.Length.ToString();
  16. }
  17.  catch (Exception ex)
  18. {
  19.        MessageBox.Show(ex.ToString());
  20.        return;
  21. }
  22.  
As result I get the server name of a gameserver running on that IP address with that port.

But how do I get more results from the datagram? Ive gotten this code from a Visual Basic program and that can see the current amount of players and map etc.

How can I get this to show in C#?
Oct 23 '08 #1
0 1031

Sign in to post your reply or Sign up for a free account.

Similar topics

2
4108
by: Dave | last post by:
Hi, This is doubtless a really dumb question but is there an elegant way of reading numbers formatted as hex from a datgram? I get a datgram which contains values like this: ---DATAGRAM--- 2aef2d43etc... ---/DATAGRAM--
0
1251
by: Jonathan Ellis | last post by:
I seem to be running into a limit of 64 queued datagrams. This isn't a data buffer size; varying the size of the datagram makes no difference in the observed queue size. If more datagrams are sent before some are read, they are silently dropped. (By "silently," I mean, "tcpdump doesn't record these as dropped packets.") This is a problem because while my consumer can handle the overall load easily, the requests often come in large...
4
33781
by: Gregory Hassett | last post by:
Hello, Does anyone know how to get the maximum size of a datagram for a UDP Socket created via .NET's System.Net.Sockets.Socket class? Thanks!
6
6278
by: Iain King | last post by:
Hi. I've been looking everywhere for this and can't find it, apologies if I'm being obtuse: How do I set the max datagram packet size? I'm using the socket module. It seem like it's hardcoded at 255, but I need it to be larger. Iain
4
2791
by: alberto.castellin | last post by:
Hi to all, I've this problem: I create a datagram socket. I create datagram socket with function 'Create'. The line of my code when I create is: m_pSocket->Create(port,SOCK_DGRAM,FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT | FD_CLOSE,strAddress); Now when I send, I' ve error in runtime at this line:
2
1417
by: DaTurk | last post by:
I know in TCP if you send a message down the wire, the OS may lump subsequent messages into a buffer before sending it across the wire, for efficiency. But, will the OS do the same thing with UDP? I'm just concerned that I may be getting multiple messages in a single datagram. I'm using a connectionless multicast paradigm where there are multiple receivers listening asynchronously, and a single sender sending synchronously.
1
3590
by: greenxiar | last post by:
My code is below and the platform is Win2K3 R2: using System; using System.Net; using System.Net.Sockets; using System.Threading; namespace TechUDPBroadcast { class Program { static void Main(string args) {
6
2348
by: 7stud | last post by:
I'm trying to understand datagrams. My client program sends a message to the server, and then the server infinitely loops over the recv() to make sure all the data was received. I'm trying to use an * to signal the end of the message, so that the server can break out of the infinite while loop used to check the recv(). However, my server repeatedly outputs the client message over and over again. Can anyone tell me why? When I start...
1
2952
by: sfncook | last post by:
Hi, As far as I can tell you can't call the accept function on a datagram socket. So why did this guy publish this sample code? http://www.codersource.net/winsock_tutorial_server_select_model.html I modified it a little to fit it into my object and get a 10045 error at the accept() function when I try to connect with a client. Thanks for any help folks.
0
9730
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5555
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5693
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4341
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.