[RESOLVED] Winsock UDP slows down to a stall. - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18

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

  1. #16
    Join Date
    Feb 2013
    Posts
    11

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

    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?

  2. #17
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,591

    Re: Winsock UDP slows down to a stall.

    Quote Originally Posted by SugarBombs View Post
    The exception was caused by the send() call. I do not have the exception text.
    The exception text is less important than the exception type here. I'd expect an InvalidOperationException as described in http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx.

    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.

  3. #18
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,591

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

    Quote Originally Posted by SugarBombs View Post
    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 09: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.

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center