CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2005
    Posts
    6

    problem with tcplistener

    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??

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: problem with tcplistener

    Have you tried with another port number?
    Maybe some other application is listening on port 5000.

    - petter

  3. #3
    Join Date
    Apr 2005
    Posts
    6

    Re: problem with tcplistener

    nope..., not yet, hahahahaha, although checking my firewall now says schvhost has that port

    dummy me :-)

    thanks!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured