Random Server Port

This is a discussion on Random Server Port within the C Programming forums, part of the General Programming Boards category; Hi, I am building an examination server. Will it be a wise idea to let the server choose a random ...

  1. #1
    Day Dreamer
    Join Date
    Apr 2007
    Posts
    45

    Random Server Port

    Hi,

    I am building an examination server.
    Will it be a wise idea to let the server choose a random port and listen on it rather than using a fixed port? And if the requirement is such, how would a client know about this random port?

    Will using an announcement help?
    I would love to change the world but they dont give me the source code!

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    It's best to have the server use a particular fixed port for listening afaik.

  3. #3
    Day Dreamer
    Join Date
    Apr 2007
    Posts
    45
    yeah, I too have known that, but someone had just confused me...
    Thanks!
    I would love to change the world but they dont give me the source code!

  4. #4
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    True, it better to prefix the port number to avoid confusions later and conflicts.

    Just in curious, I had been programming LISP for a while now, and now started to program socket using LISP. With LISP if you don't specify the port number while creating the socket, the LISP interpreter will assign a random port which are available. But how do we do that in C. Do we have a function or something to check for any available port. I know we could use some command like netstat and see what are the port have been used. And perhaps check in the /Dev/port file as well.

    And perhaps once we get the port number assigned, we could send a broadcast with port number.

    ssharish

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Concurrent chat, Sockets
    By jakemott in forum Linux Programming
    Replies: 6
    Last Post: 11-29-2008, 05:41 PM
  2. FTP program
    By jakemott in forum Linux Programming
    Replies: 14
    Last Post: 10-06-2008, 02:58 PM
  3. connecting to server with wrong port
    By liri in forum Networking/Device Communication
    Replies: 3
    Last Post: 11-13-2007, 03:52 AM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 06:49 PM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 02:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21