Socket Exception 10054 (connection reset by peer)

B

Bernd

Hello,

i have a problem with my network code.
What i want to do is, send an UDP-packet and check if i get an
icmp-reply type 3 (dest. unreachable).

the code looks like that so far:

..
..
<snip>
this.Sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram,
ProtocolType.Udp);
System.Net.IPEndPoint EndPoint = new System.Net.IPEndPoint(IP, i);
Sock.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeout, 4000);
Sock.SendTo(this.payload, this.payload.Length,
SocketFlags.None,EndPoint);
System.Net.IPEndPoint local = new
System.Net.IPEndPoint(System.Net.IPAddress.Any, 0);
System.Net.EndPoint target = (System.Net.EndPoint)local;

byte[] retPayload = new byte[1024];
int recieved = Sock.ReceiveFrom(retPayload, ref target);
<snap>
..
..

i think the problem occours here:
int recieved = Sock.ReceiveFrom(retPayload, ref target);

does anybody have an idea ?

thanks
 

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