May 4th, 2010, 05:34 AM
UdpClient is defeating me.
Most of my programming is in graphics (I lurk over at creators.xna.com) but I have an application that needs to communicate via UDP with another computer (an eye-tracking system), and I *cannot* get it working correctly, and need some help.
I'm not a programmer by trade, its just something that I manage to do (most of the time) when I need it.
I'm completly noob at network stuff, so please feel free to correct any misused terminology.
These two computers are directly connected by an ethernet cable. There is no problem with the connectivity. The remote system that I wish to interact with has proprietary software that I can install on my laptop and interact with the remote computer. I can send commands to it and it responds, and it returns the correct confirmation data that appears in the remote command software. So, the communication link is there and working both directions. I'm not getting blocked by a firewall etc.
I need to establish such connectivity via my own program, and am just having fits with it all weekend.
The address of the remote computer is 169.254.206.214, port 4444. I assume it listens on port 4444 for any data intended for its IP address.
I configure a UdpClient to send data there as:
udpClient = new UdPClient()
send_to_endpoint = new IPEndpoint(IPAddress.Parse("169.254.206.214"),4444);
Then, I encode the message to send using Encoding... and send the message as
That part works! I can get messages to the remote computer and it responds correctly.
What I cannot do is figure out how to correctly configure a udPClient to receive messages. I have seen multiple examples on the internet, but cannot get any to work.
The remote software is configured to send commands to my computers IPaddress at port 5555.
I'm not sure what IPEndpoint I should set here. I thought that the IPEndpoint would be the remote computer's IPAddress and port 5555 (e.g., listenting through port 5555 for anything from the remote computers IPaddress).
My most recent failure looks like...
listen_from_endppont = new IPEndpoint(IPaddress.Any, 5555);
sender = new IPEndpoint(IPAddress.Any, 0);
receive_client = new UdpClient(listen_from_endpoint);
byte message_bytes = receive_client.Receive(ref, sender);
I know that code should stall until a message is received, but it is never received.
I could go through the various ways I've tried to setup the listening port and been unable to receive any data back, but perhaps the simplest thing at this point is just to ask what the code should look like.
I have a remote computer at 169.254.206.214 broadcasting out of port 4444
I have a client at 169.254.47.77 working out of port 5555. I need to be able to receive simple UDP packets from the remote to the client.
I've seen enough various examples so as to say that I am really very confused about what all of this does on the receive side, and my noobness with these terms is making the MSND help of limited use.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!