HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 88
Declaring Socket Address Variables
![]() |
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 88 highlights
Using Internet Datagram Sockets Preparing Address Variables Preparing Address Variables Before your client process can make a request of the server process, you must establish the correct variables and collect the information that you need about the server process and the service provided. The server process needs to: • Declare socket address variables. • Assign a wildcard address. • Get the port address of the service that you want to provide. The client process needs to: • Declare socket address variables. • Get the remote server's internet address. • Get the port address for the service that you want to use. These activities are described next. Refer to the program example at the end of this chapter to see how these activities work together. Declaring Socket Address Variables You need to declare a variable of type struct sockaddr_in to use the local socket address for both processes. For example, the following declarations are used in the example client program: struct sockaddr_in myaddr; /* for local socket address */ struct sockaddr_in servaddr; /* for server socket address */ sockaddr_in is a special case of sockaddr and is used with the AF_INET addressing domain. Both types are shown in this chapter, but sockaddr_in makes it easier to manipulate the internet and port addresses. Some of the BSD Sockets system calls are declared using a pointer to sockaddr, but you can also use a pointer to sockaddr_in. The sockaddr_in address structure consists of the following fields: 88 Chapter 4
![](/manual_guide/products/hewlettpackard-rp5405-bsd-sockets-interface-programmers-guide-5276e7d/88.png)