[Mono-list] UDP sockets and exceptions

Dan Smithers dsmithers at talktalk.net
Mon Feb 4 09:34:21 EST 2008

Hi all,
I have a problem with my sockets.

I have a server application that opens a UDP socket on a specified port
and listens for client's requests.

I have a client application that I want to open a UDP socket choosing
from a range of ports. The client then listens at the socket for responses.

My problem is that if I run more than one client then they all end up
listening to the same socket.

All the sockets are configured using the same calls:

System.Net.Sockets.Socket sock;

sock = new System.Net.Sockets.Socket(AddressFamily.InterNetwork,
SocketType.Dgram, ProtocolType.Udp);

IPEndPoint ep = new IPEndPoint(IPAddress.Any, port);


If I try to bind the client on to the server port then an exception is
System.Net.Sockets.SocketException Address already in use.

If I try to run more than one client then I do not get this exception.

Am I doing something wrong?



More information about the Mono-list mailing list