Accepting A Connection - 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

Accepting a Connection

The server process can accept any connection requests that enter its
queue after it executes listen. accept creates a new socket for the
connection and returns the socket descriptor for the new socket. The new
socket:
• Is created with the same properties as the old socket.
• Has the same bound pathname as the old socket.
• Is connected to the client process' socket.
accept blocks until there is a connection request from a client process in
the queue, unless you are using nonblocking I/O. accept and its
parameters are described in the following table.
Include files:
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
System call:
s = accept(ls,addr,addrlen)
int s;
int ls;
struct sockaddr_un *addr;
int *addrlen;
Parameter
Contents
s
socket
descriptor of
local socket
addr
socket
address
addrlen
length of
address
Chapter 6
Using UNIX Domain Stream Sockets
Writing the Server Process
INPUT Value
socket descriptor
of server socket
pointer to address
structure where
address will be put
pointer to the size
of struct
sockaddr_un
OUTPUT
Value
unchanged
pointer to
socket address of
client socket
that server's
new socket is
connected to
pointer to the
actual length of
address
returned in addr
131

Advertisement

Table of Contents
loading

Table of Contents