[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.sdk

Re: Socket error on Udp Receive.

Clint

7/31/2003 10:31:00 AM

Thanks, that worked. The documentation is very unhelpful in this respect,
which is a shame since I always felt that this was the one thing Microsoft
did well!
Its a good thing that we have the newsgroups to fall back on....

Andy

"Jonny Yu" <jonnyyu@pub.xaonline.com> wrote in message
news:01de01c356b2$30749520$a101280a@phx.gbl...
> Dear andy,
> I've tried your code, you problem seems caused by
> haven't bind the socket with an udp port, before you do
> some receive operation.
> an socket can be binded with udp port in two ways, the
> first is by the call sendto, the system will automatically
> bind a free port for you, then you can send/receive using
> this port.
> the second way is to call the bind method explicitly,
> after binding you can go on recv msgs on it.
>
> wish you good luck!
> Jonny
> >-----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)
> >
> >
> >.
> >