[MonoDevelop] [Fwd: [Mono-list] UDP sockets and exceptions]

Dan Smithers dsmithers at talktalk.net
Mon Feb 4 11:12:23 EST 2008


Hi all,

I am posting this to the Monodevelop list as it seems to be an issue
with MD. I wrote a little command line application that opens a number
of ports and compiled it by hand using gmcs and everything worked as
expected.

I generated a MD command line application and after setting the
Project|Options Runtiume Options to use version 2 I don't get the
expected exception.

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);

sock.Bind(ep);

If I try to bind the client on to the server port then an exception is
raised
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?

thanks

dan



More information about the Monodevelop-list mailing list