home *** CD-ROM | disk | FTP | other *** search
- X-Gateway-Source-Info: INTERNET
- Path: sparky!uunet!elroy.jpl.nasa.gov!usc!news.service.uci.edu!unogate!mvb.saic.com!tgv.com!info-multinet
- Date: 20 NOV 92 21:05:10 GMT
- Newsgroups: vmsnet.networks.tcp-ip.multinet
- X-Return-path: <info-multinet-relay@TGV.COM>
- X-RFC822-From: adelman (Kenneth Adelman) @ TGV.COM
- From: adelman@TGV.COM
- Subject: Re: How can I get a free port number?
- Organization: The INFO-MULTINET Community
- Message-ID: <36A00FB320NOV92210510@TGV.COM>
- Nntp-Posting-Host: Mvb.Saic.Com
- Lines: 21
-
- > I am running Multinet 3.0 Rev. A. I was wondering if anyone could help
- > me with the following problem.
-
- > I have a computer which is booted via TCP from a VMS VAX. For reasons that
- > are long and boring, I must supply the remote computer with the number of
- > an unused TCP/IP port. This port must not be in use, in any state, at
- > the time the computer boots. Is there any call or combination of calls
- > that I could make to the Multinet subroutine library that would report to
- > me an unused, or free, port number? Alternatively, I could just sequentially
- > try port numbers if I knew of a subroutine that would tell me if a port
- > was in use (it must not even be in a time-out or fin_wait state). I'm
- > currently using a subroutine that examines the output of the
- > MULTINET SHOW/CONN command, and finds a free port by brute force, but
- > this is apt to win me few points for either elegance or efficiency.
-
- If you bind() to port 0 you'll get an unused port number assigned
- to you. You can discover it with getsockname() and then socket_close()
- the socket you bound to to free it.
-
- Ken
-