Use AF_UNIX_CCSID address family

AF_UNIX_CCSID address family sockets have the same specifications as AF_UNIX address family sockets. They can be used for connection-oriented or connectionless and provide communications on the same system.

Before working with AF_UNIX_CCSID socket application, you should be familiar with the Qlg_Path_Name_T structure to determine the output format.

When working with an output address structure, such as one returned from accept(), getsockname(), getpeername(), recvfrom(), and recvmsg(), the application must examine the socket address structure (sockaddr_unc) to determine its format. The sunc_format and sunc_qlg fields determine the output format of the path name. But sockets do not necessarily use the same values on output as the application used on input addresses.


Socket flow of events used in server and client AF_UNIX_CCSID address family example programs.

Socket flow of events: Server application that uses AF_UNIX_CCSID address family

The first example uses the following sequence of function calls:

  1. The socket() function returns a socket descriptor representing an endpoint. The statement also identifies that the UNIX_CCSID address family with the stream transport (SOCK_STREAM) are used for this socket. You can also use the socketpair() function to initialize a UNIX® socket.

    AF_UNIX or AF_UNIX_CCSID are the only address families to support the socketpair() function. The socketpair() function returns two socket descriptors that are unnamed and connected.

  2. After the socket descriptor is created, the bind() function gets a unique name for the socket.

    The name space for UNIX domain sockets consists of path names. When a sockets program calls the bind() function, an entry is created in the file system directory. If the path name already exists, the bind() fails. Thus, a UNIX domain socket program should always call an unlink() functions to remove the directory entry when it ends.

  3. The listen() allows the server to accept incoming client connections. In this example, the backlog is set to 10. This means that the system queues 10 incoming connection requests before the system starts rejecting the incoming requests.
  4. The server uses the accept() function to accept an incoming connection request. The accept() call blocks indefinitely waiting for the incoming connection to arrive.
  5. The recv() function receives data from the client application. In this example, the client sends 250 bytes of data over. Thus the SO_RCVLOWAT socket option can be used, specifying that recv() is not required to wake up until all 250 bytes of data have arrived.
  6. The send() function echoes the data back to the client.
  7. The close() function closes any open socket descriptors.
  8. The unlink() function removes the UNIX path name from the file system.

Socket flow of events: Client application that uses AF_UNIX_CCSID address family

The second example uses the following sequence of function calls:

  1. The socket() function returns a socket descriptor representing an endpoint. The statement also identifies that the UNIX address family with the stream transport (SOCK_STREAM) is used for this socket. The function returns a socket descriptor representing an endpoint. You can also use the socketpair() function to initialize a UNIX socket.

    AF_UNIX or AF_UNIX_CCSID are the only address families to support the socketpair() function. The socketpair() function returns two socket descriptors that are unnamed and connected.

  2. After the socket descriptor is received, the connect() function is used to establish a connection to the server.
  3. The send() function sends 250 bytes of data that are specified in the server application with the SO_RCVLOWAT socket option.
  4. The recv() function loops until all 250 bytes of the data have arrived.
  5. The close() function closes any open socket descriptors.
Related reference
AF_UNIX_CCSID address family
Use AF_UNIX address family
Related information
Path name format
recvfrom()
accept()
getpeername()
getsockname()
recvmsg()
close()
socket()
bind()
unlink()
listen()
send()
connect()
recv()
socketpair()