c# UDP socket source address

A

alex tomlinsom

I've got a c# socket that is open and listening to incoming UDP packets on a port. When the packet comes in, I want to figure out what address it came from. The problem seems to be that while the callback (im using async sockets here) comes in,
it's only giving me the payload of the datagram. There doesn't seem to be any way to see the packet header at all. Am I just missing something obvious or is there another way to do this?
 
J

Johann Blake

Alex,

The RemoteEndPoint property of a socket returns the address.

Best Regards
Johann Blake
 
A

alex tomlinsom

You didn't read the question. This is a connectionless UDP socket with overlapped asynchronus IO. The socket will be getting packets from thousands of machines, how would looking at the socket objects endpoint help me? By the time the code
executes to give me that it could have received 5 more packets from different hosts.
 
J

Johann Blake

Alex,

I read your question and I believe I answered it correctly. Your
initial post made no mention of multiple clients being serviced by a
single socket.

I wrote an application that does what you describe and have no problem
obtaining the IP address of any client, even when using a single socket
to handle all connections.

Best Regards
Johann Blake
 
A

alex tomlinsom

ok, maybe I'm missing something here but there are no connections. It's a UDP socket, so packets come in from lots of different places. I can't check the connection properties because there aren't any.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top