Creates a new TCP socket of the specified address family.
#include <prio.h> PRFileDesc* PR_OpenTCPSocket(PRIntn af);
The function has the following parameters:
- The address family of the new TCP socket. Can be
PR_AF_LOCAL(Unix domain, supported on POSIX systems only).
The function returns one of the following values:
- Upon successful completion, a pointer to the
PRFileDescobject created for the newly opened TCP socket.
- If the creation of a new TCP socket failed,
TCP (Transmission Control Protocol) is a connection-oriented, reliable byte-stream protocol of the TCP/IP protocol suite.
PR_OpenTCPSocket creates a new TCP socket of the address family
af. A TCP connection is established by a passive socket (the server) accepting a connection setup request from an active socket (the client). Typically, the server binds its socket to a well-known port with
PR_Listen to start listening for connection setup requests, and calls
PR_Accept to accept a connection. The client makes a connection request using
After a connection is established, the client and server may send and receive data between each other. To receive data, one can call
PR_Recv. To send data, one can call
PR_AcceptRead is suitable for use by the server to accept a new client connection and read the client's first request in one function call.