tor-browser

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

pr_bind.rst (1329B)


      1 PR_Bind
      2 =======
      3 
      4 Binds an address to a specified socket.
      5 
      6 
      7 Syntax
      8 ------
      9 
     10 .. code::
     11 
     12   #include <prio.h>
     13 
     14   PRStatus PR_Bind(
     15     PRFileDesc *fd,
     16     const PRNetAddr *addr);
     17 
     18 
     19 Parameters
     20 ~~~~~~~~~~
     21 
     22 The function has the following parameters:
     23 
     24 ``fd``
     25   A pointer to a :ref:`PRFileDesc` object representing a socket.
     26 ``addr``
     27   A pointer to a :ref:`PRNetAddr` object representing the address to which
     28   the socket will be bound.
     29 
     30 
     31 Returns
     32 ~~~~~~~
     33 
     34 The function returns one of the following values:
     35 
     36 -  Upon successful binding of an address to a socket, ``PR_SUCCESS``.
     37 -  If unsuccessful, ``PR_FAILURE``. Further information can be obtained
     38   by calling :ref:`PR_GetError`.
     39 
     40 
     41 Description
     42 -----------
     43 
     44 When a new socket is created, it has no address bound to it. :ref:`PR_Bind`
     45 assigns the specified address (also known as name) to the socket. If you
     46 do not care about the exact IP address assigned to the socket, set the
     47 ``inet.ip`` field of :ref:`PRNetAddr` to :ref:`PR_htonl`\ (``PR_INADDR_ANY``).
     48 If you do not care about the TCP/UDP port assigned to the socket, set
     49 the ``inet.port`` field of :ref:`PRNetAddr` to 0.
     50 
     51 Note that if :ref:`PR_Connect` is invoked on a socket that is not bound, it
     52 implicitly binds an arbitrary address the socket.
     53 
     54 Call :ref:`PR_GetSockName` to obtain the address (name) bound to a socket.