Create a connection with connection oriented sockets
Call socket() on
srvr
PCO with the following parameters:domain
,SOCK_STREAM
,proto
. Created socket is referred assrvr_s
below;If
srvr_wild
is true, fill in network address part ofsrvr_bind_addr
with wildcard network address;Copy port part of
srvr_addr
to port part ofsrvr_bind_addr
address;Bind
srvr_s
socket tosrvr_bind_addr
address.If port part of
srvr_addr
is zero (not specified), then call getsockname() onsrvr_s
socket to obtain the assigned port and set it to the port part ofsrvr_addr
.Call listen() for
srvr_s
socket with default backlog.
SOCK_STREAM
Call socket() on clnt PCO with the following parameters:
domain
,SOCK_STREAM
,proto
. Created socket is referred asclnt_s
below.If
clnt_addr
is not equal toNULL
, bind()clnt_s
socket toclnt_addr
address.Initiate accept() for
srvr_s
socket;Call connect() to connect client socket
clnt_s
to server withsrvr_addr
address;Wait for accept() completion to get
accepted_s
socket;Close srvr_s socket
Set
accepted_s
tosrvr_s
variable.
Parameters:
srvr |
PCO for server |
clnt |
PCO for client |
domain |
Domain used in the connection |
proto |
Protocol used in the connection |
srvr_addr |
server address (cannot be |
srvr_wild |
bind server to wildcard address or not (although we must specify network address in |
clnt_addr |
address to bind client to or |
srvr_s |
|
clnt_s |
|