How to locate a server and its port #? - TCP-IP

This is a discussion on How to locate a server and its port #? - TCP-IP ; Hi I need to rewrite a single-user application into a multi-user version. For this, I'll have to run a server process on a host somewhere on their LAN. Since the users aren't very technical, I'd like to make this as ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: How to locate a server and its port #?

  1. How to locate a server and its port #?

    Hi

    I need to rewrite a single-user application into a multi-user
    version. For this, I'll have to run a server process on a host
    somewhere on their LAN.

    Since the users aren't very technical, I'd like to make this as easy
    as possible, and that includes locating the host acting as the server,
    and finding the port number on which it's listening for queries.

    Clients could use a broadcast to locate the server... but for this to
    work, the server must be able to listen on a specific port... which
    might not be available. Catch22.

    Is there a solution to this, or do I have to...
    1. launch the server on a port, and if it's not available, try another
    one at random until it finds one that's available, and display the
    port it's listening on in the interface so users can tell
    2. launch the client to connect to the default port, and if it can't
    connect, tell users to walk to the host that's acting as server, read
    the port it's listening on, and type it manually in the client?

    Thank you.

  2. Re: How to locate a server and its port #?

    In article ,
    Gilles Ganault wrote:

    > Hi
    >
    > I need to rewrite a single-user application into a multi-user
    > version. For this, I'll have to run a server process on a host
    > somewhere on their LAN.
    >
    > Since the users aren't very technical, I'd like to make this as easy
    > as possible, and that includes locating the host acting as the server,
    > and finding the port number on which it's listening for queries.


    My guess is you want to implement zeroconf (google or wikipedia should give
    you enough to get started).

  3. Re: How to locate a server and its port #?

    In article ,
    Gilles Ganault wrote:

    > Hi
    >
    > I need to rewrite a single-user application into a multi-user
    > version. For this, I'll have to run a server process on a host
    > somewhere on their LAN.
    >
    > Since the users aren't very technical, I'd like to make this as easy
    > as possible, and that includes locating the host acting as the server,
    > and finding the port number on which it's listening for queries.
    >
    > Clients could use a broadcast to locate the server... but for this to
    > work, the server must be able to listen on a specific port... which
    > might not be available. Catch22.
    >
    > Is there a solution to this, or do I have to...
    > 1. launch the server on a port, and if it's not available, try another
    > one at random until it finds one that's available, and display the
    > port it's listening on in the interface so users can tell
    > 2. launch the client to connect to the default port, and if it can't
    > connect, tell users to walk to the host that's acting as server, read
    > the port it's listening on, and type it manually in the client?


    You could use the portmapper protocol. If the server is a Unix system,
    it's most likely running the portmap service.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  4. Re: How to locate a server and its port #?

    On Sun, 19 Aug 2007 18:03:26 -0400, Roy Smith wrote:
    >My guess is you want to implement zeroconf (google or wikipedia should give
    >you enough to get started).


    Thanks guys. Forgot to mention 1) it's an all Windows context so
    portmap won't do, 2) I'd rather minimize setup, so deploying
    zeroconf/bonjour is too much work.

    For those interested in doing the same thing, elsewhere, someone
    mentionned using NetBIOS to register a name on the server so that
    clients can locate it through a broadcast, and then use named pipes to
    actually TX/RX data. I was thinking of just having the server send the
    IP port on which it's listening, but named pipes might be good enough
    to also send real data once the two hosts are connected.

    Thank you.

  5. Re: How to locate a server and its port #?

    On Aug 20, 4:59 am, Gilles Ganault wrote:
    > On Sun, 19 Aug 2007 18:03:26 -0400, Roy Smith wrote:
    > >My guess is you want to implement zeroconf (google or wikipedia should give
    > >you enough to get started).

    >
    > Thanks guys. Forgot to mention 1) it's an all Windows context so
    > portmap won't do, 2) I'd rather minimize setup, so deploying
    > zeroconf/bonjour is too much work.
    >
    > For those interested in doing the same thing, elsewhere, someone
    > mentionned using NetBIOS to register a name on the server so that
    > clients can locate it through a broadcast, and then use named pipes to
    > actually TX/RX data. I was thinking of just having the server send the
    > IP port on which it's listening, but named pipes might be good enough
    > to also send real data once the two hosts are connected.
    >
    > Thank you.


    Why not do what the normal DHCP protocol does..
    i.e.

    1) Make the client application send a broadcast.
    2) Let the server reply back with the IP / port no.

    This of course assumes a couple of things
    1) You can modify the client program to implement this protocol.
    2) Client & server resides on the same LAN (in the absence of
    proprietary relay agents on routers)


    --Debashis Dutt


  6. Re: How to locate a server and its port #?

    On Aug 19, 8:18 am, Gilles Ganault wrote:
    > Hi
    >
    > I need to rewrite a single-user application into a multi-user
    > version. For this, I'll have to run a server process on a host
    > somewhere on their LAN.
    >
    > Since the users aren't very technical, I'd like to make this as easy
    > as possible, and that includes locating the host acting as the server,
    > and finding the port number on which it's listening for queries.
    >
    > Clients could use a broadcast to locate the server... but for this to
    > work, the server must be able to listen on a specific port... which
    > might not be available. Catch22.
    >
    > Is there a solution to this, or do I have to...

    [snip]

    Why don't you just execute the "standard practice"?
    - On the server, hardcode the logic to watch a specific port (or
    service name). Use one that you know (or are reasonably certain) is
    not in use by another server.

    - On the client, hardcode the logic to connect to the same specific
    port that you selected for your server.





  7. Re: How to locate a server and its port #?

    In article <1187633641.690851.4650@r34g2000hsd.googlegroups.co m>,
    debdut wrote:

    >> Thanks guys. Forgot to mention 1) it's an all Windows context so
    >> portmap won't do, 2) I'd rather minimize setup, so deploying
    >> zeroconf/bonjour is too much work.
    >>
    >> For those interested in doing the same thing, elsewhere, someone
    >> mentionned using NetBIOS to register a name on the server so that



    >Why not do what the normal DHCP protocol does..
    >i.e.
    >
    >1) Make the client application send a broadcast.
    >2) Let the server reply back with the IP / port no.
    >
    >This of course assumes a couple of things
    >1) You can modify the client program to implement this protocol.
    >2) Client & server resides on the same LAN (in the absence of
    > proprietary relay agents on routers)


    Those are insignificant assumptions compared to the big one. The
    big assumption is of a port number that would be the target of those
    broadcssts. DHCP, NetBIOS, zeroconf/bonjour, and portmap all use
    broadcasts to known UDP port numbers.

    Note also that DHCP servers need not be on the same LAN, thanks to
    relaying agents that I'd not call "proprietary."

    The modern alternative to broadcasts would probably be site- or
    organization-local multicasts. See RFC 2365. This would also
    avoid the need for relaying agents.


    I would do (and have done) what Lew Pitcher described in article
    <1187636421.527548.183000@r34g2000hsd.googlegroups. com>,

    }Why don't you just execute the "standard practice"?
    }- On the server, hardcode the logic to watch a specific port (or
    }service name). Use one that you know (or are reasonably certain) is
    }not in use by another server.
    }
    }- On the client, hardcode the logic to connect to the same specific
    }port that you selected for your server.



    Vernon Schryver vjs@rhyolite.com

  8. Re: How to locate a server and its port #?

    In article <1187633641.690851.4650@r34g2000hsd.googlegroups.co m>,
    debdut wrote:

    > On Aug 20, 4:59 am, Gilles Ganault wrote:
    > > On Sun, 19 Aug 2007 18:03:26 -0400, Roy Smith wrote:
    > > >My guess is you want to implement zeroconf (google or wikipedia should give
    > > >you enough to get started).

    > >
    > > Thanks guys. Forgot to mention 1) it's an all Windows context so
    > > portmap won't do, 2) I'd rather minimize setup, so deploying
    > > zeroconf/bonjour is too much work.
    > >
    > > For those interested in doing the same thing, elsewhere, someone
    > > mentionned using NetBIOS to register a name on the server so that
    > > clients can locate it through a broadcast, and then use named pipes to
    > > actually TX/RX data. I was thinking of just having the server send the
    > > IP port on which it's listening, but named pipes might be good enough
    > > to also send real data once the two hosts are connected.
    > >
    > > Thank you.

    >
    > Why not do what the normal DHCP protocol does..
    > i.e.
    >
    > 1) Make the client application send a broadcast.
    > 2) Let the server reply back with the IP / port no.


    What port does it send this broadcast to? Remember, the problem he's
    trying to solve is that he can't be sure that the port is available.

    --
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    *** PLEASE don't copy me on replies, I'll read them in the group ***

  9. Re: How to locate a server and its port #?

    On Aug 20, 4:35 pm, Barry Margolin wrote:
    > In article <1187633641.690851.4...@r34g2000hsd.googlegroups.co m>,
    >
    >
    >
    > debdut wrote:
    > > On Aug 20, 4:59 am, Gilles Ganault wrote:
    > > > On Sun, 19 Aug 2007 18:03:26 -0400, Roy Smith wrote:
    > > > >My guess is you want to implement zeroconf (google or wikipedia should give
    > > > >you enough to get started).

    >
    > > > Thanks guys. Forgot to mention 1) it's an all Windows context so
    > > > portmap won't do, 2) I'd rather minimize setup, so deploying
    > > > zeroconf/bonjour is too much work.

    >
    > > > For those interested in doing the same thing, elsewhere, someone
    > > > mentionned using NetBIOS to register a name on the server so that
    > > > clients can locate it through a broadcast, and then use named pipes to
    > > > actually TX/RX data. I was thinking of just having the server send the
    > > > IP port on which it's listening, but named pipes might be good enough
    > > > to also send real data once the two hosts are connected.

    >
    > > > Thank you.

    >
    > > Why not do what the normal DHCP protocol does..
    > > i.e.

    >
    > > 1) Make the client application send a broadcast.
    > > 2) Let the server reply back with the IP / port no.

    >
    > What port does it send this broadcast to? Remember, the problem he's
    > trying to solve is that he can't be sure that the port is available.
    >
    > --
    > Barry Margolin, bar...@alum.mit.edu
    > Arlington, MA
    > *** PLEASE post questions in newsgroups, not directly to me ***
    > *** PLEASE don't copy me on replies, I'll read them in the group ***


    Yes, you are right, I overlooked the fact the port number is also
    unknown in this case. I apologize.


  10. Re: How to locate a server and its port #?

    On Aug 19, 5:18 am, Gilles Ganault wrote:

    > Clients could use a broadcast to locate the server... but for this to
    > work, the server must be able to listen on a specific port... which
    > might not be available. Catch22.


    Apply for your own reserved port. Last I checked, a decade ago or so,
    they weren't particularly hard to get. Then if someone else is using
    your port, you are clearly in the right.

    DS


+ Reply to Thread