Operating System - OpenVMS
1840623 Members
2378 Online
110166 Solutions
New Discussion

Re: Specifying server tcp socket address in a client program

 
SOLVED
Go to solution
Jeff Dowbenko
New Member

Specifying server tcp socket address in a client program

I have been able to create a socket and connect to a server in a "c" client program using host name and port.

How can I do the same when all I have is the host name (DNS has the port number)?
8 REPLIES 8
Robert Gezelter
Honored Contributor

Re: Specifying server tcp socket address in a client program

Jeff,

What (precisely) do you mean by "(DNS has the port number)"?

In the simplest interpretation of your question, the answer is: Resolve the port number using a DNS query (probably using the C-socket library), then insert the information into the appropriate control block for the socket calls.

More information would be appreciated, however.

- Bob Gezelter, http://www.rlgsc.com
Steven Schweda
Honored Contributor

Re: Specifying server tcp socket address in a client program

Since when did DNS deal with _port_ numbers?

_Service_ names can be translated into port
numbers (by getservbyname(), for example).
Jeff Dowbenko
New Member

Re: Specifying server tcp socket address in a client program

Below is what was given to me by the owner of the application server I am attempting to connect to. The first address (test env) contains host and port - no problem.

The second (production env) contains just host and you can see the comments they sent with respect to DNS. I crossed out our internal domain name so it dosn't become public.

"You will not have to include the port number, the DNS uses the default HTTP port, 80. Then DNS routes the request to the linux servers on the correct port.

So, before:
http://lnx429.xxxx.com:42472/opiws/.........

In Production:
http://opiws.serv.xxxx.com/opiws/......."


When I use the production host name and a port of 80, of course everything works. If I use the production host name and no port, I get an IOSB status of 308 which is -
%SYSTEM-F-IVADDR, invalid media address.

Thanks

Jeff
Robert Gezelter
Honored Contributor

Re: Specifying server tcp socket address in a client program

Jeff,

From the snippet that you posted, it would appear that the correct port is 80 (the convention for the assignment for an HTTP server).

This is not a function of DNS. The test case that you included contains a port number as part of the URL. The DNS name of the server is extracted from the URL before (emphasis BEFORE) the name is supplied to the DNS clerk for translation to an IP address.

- Bob Gezelter, http://www.rlgsc.com
Steven Schweda
Honored Contributor

Re: Specifying server tcp socket address in a client program

> "You will not have to include the port
> number, the DNS uses the default HTTP
> port, 80. Then DNS routes the request to
> the linux servers on the correct port.

This guy's drooling. DNS has nothing to do
with the port number, only the translation
from the name to the IP address. Also, DNS
does not "route" anything.

Web browsers (and related programs) use port
80 by default for the "http" scheme. For
the names of other popular schemes, see, for
example:

http://en.wikipedia.org/wiki/URL

You _always_ need to specify a port number.
The only question is whether to use the port
number specified explicitly by someone else
(like 42472), or to use the port number of
your own choice (like 80). It helps if you
choose the port number where the desired
server application is listening.

On a UNIX system, the service name to port
number translation table is often found in
/etc/services (or a similar NIS data base).
On VMS, it depends on whose TCP/IP package.
("TCPIP SHOW SERVICE", for HP's TCPIP.)
Joseph Huber_1
Honored Contributor

Re: Specifying server tcp socket address in a client program

And note that getservbyname() gets the port number from LOCAL setup, not the remote system:
And especially for HTTP in VMS, it depends from the TCPIP stack and the HTTP server software, if there is a service defined.

For HP TCPIP services (UCX) and the OSU HTTP server for example there is nothing defined , the port is established dynamically at OSU startup.

So You have to communicate with the remote systems manager to stay in synch.

What You could do to keep the application unchanged (by using getservbyname("HTTP",&port) ), is to establish a dummy HTTP service just to define the service port. So in case the HTTP port would change, only the TCPIP service setup would have to be changed, not the application program using it.
http://www.mpp.mpg.de/~huber
Jim_McKinney
Honored Contributor
Solution

Re: Specifying server tcp socket address in a client program

Previous replies are correct... and if they doesn't push you in the right direction maybe this will.

It was written

> So, before:
> http://lnx429.xxxx.com:42472/opiws/.........
>
> In Production:
> http://opiws.serv.xxxx.com/opiws/......."


By convention

http://opiws.serv.xxxx.com/opiws/

is equivalent to

http://opiws.serv.xxxx.com:80/opiws/

Jeff Dowbenko
New Member

Re: Specifying server tcp socket address in a client program

Thanks all...

Jeff