.NET UDPClient

DragonWolf
DragonWolf used Ask the Experts™
on
Hi all,

    I'm having trouble getting the UDPClient to work with VB.NET (I havn't tried in C# or C/C++).
The udpClient has connected and sent a signal to 127.0.0.1 on port 11000 with no exceptions thrown. On the below line of code,

Dim receiveBytes As [Byte]() = udpClient.Receive(RemoteIpEndPoint)

I receive the below exception error,

System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
   at System.Net.Sockets.Socket.ReceiveFrom(Byte[] buffer, Int32 size, SocketFlags socketFlags, EndPoint& remoteEP)
   at System.Net.Sockets.UdpClient.Receive(IPEndPoint& remoteEP)
   at WindowsApplication4.Form1.Button1_Click(Object sender, EventArgs eClick) in C:\Documents and Settings\ellisb\My Documents\Visual Studio Projects\WindowsApplication4\Form1.vb:line 132

RemoteIPEndPoint is defined using the following line of code,

            Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)

    Any ideas why it throws the exception and how to solve it?

    Cheers in advance.

    DW
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Take a look at the first link. I think this has the answer to your problem..

http://www.codeproject.com/buglist/udpclientbug.asp

you can also take a loot at this link.
http://www.vbip.com/books/1861007353/chapter_7353_04.asp

Author

Commented:
Its definatly interesting and a problem I would run into. Thanks for point it out.

But I don't think this is the problem I have encountered, I'll have to do a bit more digging into it.
Most Valuable Expert 2012
Top Expert 2008

Commented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by naveenkohli

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheLearnedOne
EE Cleanup Volunteer

Commented:
I believe Experts Exchange had requested that comments not include links as a stand alone answer.  One of the reasons is now very evident.  Neither link in the Accepted solution works, so the question no longer has an answer.  

I'd love to know what it was though.

Author

Commented:
The first link works for me.

The second can be found through the internet archive http://www.archive.org/

i.e. http://web.archive.org/web/20070104114431/http://www.vbip.com/books/1861007353/chapter_7353_04.asp

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial