HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 31
Preparing Address Variables
![]() |
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 31 highlights
Using Internet Stream Sockets Preparing Address Variables Preparing Address Variables Before you create a connection, establish the correct variables and collect the information that you need to request a connection. Your server process needs to: • Declare socket address variables. • Assign a wildcard address. • Get the port address of the service that you want to provide. Your client process needs to: • Declare socket address variables. • Get the remote host'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 for socket addresses. For example, the following declarations are used in the example client program: struct sockaddr_in myaddr; /* for local socket address */ struct sockaddr_in peeraddr; /* for peer 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: Chapter 2 31
![](/manual_guide/products/hewlettpackard-rp5405-bsd-sockets-interface-programmers-guide-5276e7d/31.png)