Preparing Address Variables; Declaring Socket Address Variables - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

Using UNIX Domain 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 you need
about the server process.
Your server process needs to:
• Declare socket address variables.
• Get the pathname (character string) for the service you want to
provide.
Your client process needs to:
• Declare socket address variables.
• Get the pathname (character string) for the service 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_un to use for the
socket address for both processes. For example, the following declaration
is used in the example server program:
struct sockaddr_un
sockaddr_un is a special case of sockaddr and is used with AF_UNIX
address domain. The sockaddr_un address structure is defined in
sys/un.h and consists of the following fields:
Field
short sun_family
u_char sun_path[92]
150
servaddr;
/* server socket address */
Description
Specifies the address family and should
always be set to AF_UNIX.
Specifies the pathname to which the
socket is bound or will be bound (e.g.:
/tmp/myserver).
Chapter 7

Advertisement

Table of Contents
loading

Table of Contents