If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

The code is now using the output parameter of EndReceive() to gather the IP address of the client. From there the receiving socket is closed and a sending socket with the acquired IP address is open to send a reply. I would imagine there is a way to send data back without opening another socket. [...]

As I understand your scenario, I'd first set up a UdpClient without specifying a remote host (IPEndPoint or host name). Then wait for a packet matching my protocol. When I get one I'd either settle the remote host for the UDP client I already have to the endpoint that just sent the packet in case I plan to serve just one remote host, or create another UDP client with the endpoint settled upon construction and keep the original UDP client as a promiscuous receiver for further remote host discovery. In the latter scenario, you'd have one dedicated UDP client for each discovered remote host which may seem quite some effort, but eventually it will probaly be simpler than routing all communication over the promiscuous client and dispatch it yourself. However, of course, the choice is up to you.

The udpClient in your ReceiveCallback() clearly is a local variale, but what about the one in the code before that? I can't tell that which illustrates the importance of at least posting complete functions as code snippets in most scenarios. Creating UDP clients as local variables probably seems at least counter-productive performance-wise, since they get created and destroyed over and over, but it may also break your code in case the packets you expect to receive with one client have already been consumed by another one with a longer lifetime that already existed.

Well, I would like to offer beer money for your time in replying to my newbie questions, just PM a PayPal address if you wish. [...]

Unfortunately I don't have such an address. Do you happen to have a link to a free Android virtual beer app until I get one?

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Re: [RESOLVED] Winsock UDP slows down to a stall.

Originally Posted by SugarBombs

Quick question, do I need to make a new class for UdpState or is there a way to incorporate the object into the form class?

As I already mentioned in post #12 I don't see a need for that class in your scenario. To incorporate the respective information into your form class simply make the two UdpState component variables ordinary instance members of the form class.

Last edited by Eri523; February 17th, 2013 at 08:40 PM.

I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.