Re: TCP/IP
In article <1141717834.523474.44920@j33g2000cwa.googlegroups. com>,
Prince <princevictor.moses@gmail.com> wrote:
> I working on a client/server application in EVC.
> The client is one place and server is in another place.
> I want to connect the client with server using TCP/IP.
> How shall I specify the IP address of the server in the client side?
> Where I should use the domain name or ??
Using a domain name is a convenience, so that you do not need to
change the code if the server should need to change IP address.
I would use hardcoded IP addresses:
- on systems that made it difficult to resolve IP addresses
- for code that only had to survive for a short time, where the
extra effort of setting up a Domain Name System (DNS) was not
worth the effort
- for code that only had to survive a short time, where the cost ($$$)
of setting up a domain name was not worth it
- if network security policies made it impractical or impossible to use
DNS resolution
- on systems with very restricted resources where DNS would use
more resources than the convenience warranted
If you are asking what code you need to use in order to supply a
hostname instead of an IP address, then the answer depends upon
which operating system you are using. Typically, you would use
gethostbyname(), passing in a string that might be either the
text version of the name or the text version of the IP address.
gethostbyname() returns a pointer to a static structure, one
of the members of which is a list of IP addresses in binary
format, in "network order". If your OS needs you to provide
binary addresses in "host order" then use ntohl() on the address
in "network order" to convert to "host order".
|