[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

Socket error on Udp Receive.

Jonny Yu

7/30/2003 3:55:00 PM

Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
byte[] bytes = new byte[100];
//you should first call sendTo, if you use this socket
//in client way.
//or you should call bind first ,if you want this socket
//be an udp server socket
s.SendTo (bytes,new IPEndPoint(IPAddress.Parse
("192.168.0.8"),135));
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
EndPoint tempRemoteEP = sender;
s.ReceiveFrom(bytes,ref tempRemoteEP);

>-----Original Message-----
>Could someone please explain the error message that I get
in the code below.
>
>This started out as an attempt to get UdpClients talking
politely but I got
>the same error
>
>as I get here.
>
>Thanks,
>
>Andy
>
>
>
>Socket s = new Socket(AddressFamily.InterNetwork,
SocketType.Dgram,
>ProtocolType.Udp);
>
>// Creates an IpEndPoint to capture the identity of the
sending host.
>
>IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
>
>EndPoint tempRemoteEP = (EndPoint)sender;
>
>// Creates a byte buffer to receive the message.
>
>byte[] buffer = new byte[1024];
>
>// Receives datagram from a remote host. This call blocks.
>
>s.ReceiveFrom(buffer, ref tempRemoteEP); <===
Socket Error 10022
>(Invalid argument)
>
>
>.
>