tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

pr_newtcpsocket.rst (1792B)


      1 PR_NewTCPSocket
      2 ===============
      3 
      4 Creates a new IPv4 TCP socket.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prio.h>
     13 
     14   PRFileDesc* PR_NewTCPSocket(void);
     15 
     16 
     17 Returns
     18 ~~~~~~~
     19 
     20 The function returns one of the following values:
     21 
     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``.
     25 
     26 
     27 Description
     28 -----------
     29 
     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`.
     38 
     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.
     45 
     46 A TCP connection can be shut down by :ref:`PR_Shutdown`, and the sockets
     47 should be closed by :ref:`PR_Close`.
     48 
     49 
     50 See Also
     51 --------
     52 
     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.