Bug 1885489 - Part 9: Add SnapshotIterator::readObject(). r=iain
[gecko.git] / docs / nspr / reference / pr_newtcpsocket.rst
blob4a6b285669bc0e03d32f8e9782d3b630fee5a6a9
1 PR_NewTCPSocket
2 ===============
4 Creates a new IPv4 TCP socket.
7 Syntax
8 ------
10 .. code::
12    #include <prio.h>
14    PRFileDesc* PR_NewTCPSocket(void);
17 Returns
18 ~~~~~~~
20 The function returns one of the following values:
22 -  Upon successful completion, a pointer to the :ref:`PRFileDesc` object
23    created for the newly opened IPv4 TCP socket.
24 -  If the creation of a new TCP socket failed, ``NULL``.
27 Description
28 -----------
30 TCP (Transmission Control Protocol) is a connection-oriented, reliable
31 byte-stream protocol of the TCP/IP protocol suite. :ref:`PR_NewTCPSocket`
32 creates a new IPv4 TCP socket. A TCP connection is established by a
33 passive socket (the server) accepting a connection setup request from an
34 active socket (the client). Typically, the server binds its socket to a
35 well-known port with :ref:`PR_Bind`, calls :ref:`PR_Listen` to start listening
36 for connection setup requests, and calls :ref:`PR_Accept` to accept a
37 connection. The client makes a connection request using :ref:`PR_Connect`.
39 After a connection is established, the client and server may send and
40 receive data between each other. To receive data, one can call
41 :ref:`PR_Read` or :ref:`PR_Recv`. To send data, one can call :ref:`PR_Write`,
42 :ref:`PR_Writev`, :ref:`PR_Send`, or :ref:`PR_TransmitFile`. :ref:`PR_AcceptRead` is
43 suitable for use by the server to accept a new client connection and
44 read the client's first request in one function call.
46 A TCP connection can be shut down by :ref:`PR_Shutdown`, and the sockets
47 should be closed by :ref:`PR_Close`.
50 See Also
51 --------
53 :ref:`PR_NewTCPSocket` is deprecated because it is hardcoded to create an
54 IPv4 TCP socket. New code should use :ref:`PR_OpenTCPSocket` instead, which
55 allows the address family (IPv4 or IPv6) of the new TCP socket to be
56 specified.