Results 1 to 8 of 8

Thread: Which Port Revisted!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167

    Which Port Revisted!

    Hello.

    When writing socket programs which comunicate with eachother over IP, how do you choose which port they should use?



    What happens when another process tries to use the same port?

    Cheers!
    Last edited by Justy; Aug 13th, 2003 at 08:24 AM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167
    No insights?

    Is is ok to just randomly choose a port number?

  3. #3
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    choose any nyumber above 2000 and you will be fine.

    If two programs use same port then one will not work

    HTH
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    For good proper redundancy you might try selecting a wide range of port numbers. So your app will listen on port 2000, 2100, 2200, 2250, 2260, 2270, 2280, 2290, 2295, 2300

    Chances are at least one should be free. And when another app is trying to connect, if it doesn't receive the correct handshake protocol upon connect, then that's another app already running on that computer...
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167
    Thanks fellas...


  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167
    OK I'm back..............

    Right well the reason I was asking about ports is that I'm writing a windows service in VB.NET which accepts socket requests from client programs and verifies license information.

    Sometimes, and only sometimes, I get the following error when trying to start the service:

    "Only one usage of each socket address (protocol/network address/port) is normally permitted"

    Now I've tried lots of different port numbers and this keeps happening now and again. Is it possible for a process to 'hold on' to a port after it has been stopped? Perhaps there is another reason for encountering this problem?

  7. #7
    KING BODWAD XXI BodwadUK's Avatar
    Join Date
    Aug 2002
    Location
    Nottingham
    Posts
    2,176
    If you keep only one server winsock listening and then load up any new ones to accept the connection then you should avoid this.

    it is a winsock problem where one has not released the port properly and will take up to a minute after finishing to free the port.

    I THINK
    If you dribble then you are as mad as me

    Lost World Creations Website (XBOX Indie games)
    Lene Marlin

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2002
    Location
    Belfast, N. Ireland
    Posts
    167
    Thing is.. it sometimes gives me this error messages even after I have just restarted the computer and run the service for the first time..

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