Click to See Complete Forum and Search --> : problem with tcplistener


CamonZ
April 24th, 2005, 02:58 PM
hi, i'm trying to program a simple server using sockets, and when I initialize the tcplistener i get an exception, and the program halts excution


here's a piece of code

private IPAddress ipadd;
ipadd = Dns.GetHostByName("localhost").AddressList[0];
TcpListener listener;
try{
listener = new TcpListener(ipadd,5000);


listener.Start(); //this is the line of code that gives the Exception
//some more lines of code

}
catch(SocketException error)
{
MessageBox.Show( error.ToString());
}

the thing is that the exception message is

System.Net.Sockets.SocketException ; only one usage of each socket address (protocol,network address,port) is normally permited

then the program halts execution. now my question is the following: why if i'm declaring that listener = new TcpListener(ipadd,5000);
i'm getting this error, i've already tryed the option of TcpListener(5000) and i still get this error

how can i fix it??

wildfrog
April 24th, 2005, 05:54 PM
Have you tried with another port number?
Maybe some other application is listening on port 5000.

- petter

CamonZ
April 24th, 2005, 05:58 PM
nope..., not yet, hahahahaha, although checking my firewall now says schvhost has that port

dummy me :-)

thanks!!!