Functions and Directives

Function SocketBind() Professional

Associates a local address with a socket.

Syntax
SocketBind( <nSocket>         , ;
            [<nAddressFamily>], ;
            <xLocalAddress    , ;
            <nPort>           , ;
            [@<nError>]         ) --> lSuccess
Parameters
<nSocket>
This is a numeric socket descriptor previously created with SocketNew() or SocketCreate().
<nAddressFamily>
This parameter specifies the adress family to which the socket belongs to. Windows only supports the #define constant AF_INET as value, which is the default.
<xLocalAddress>
The local address can be specified either as a numeric address in network byte order, or as a character string. The latter can be coded as the DNS name of the computer or as IP address in form of a dotted octet string.
<nPort>
This is the numeric port number on the local computer to bind the socket to.
<nError>
If this parameter is passed by reference to the function, it gets assigned a numeric error code when the function fails. #define constants beginning with WSAE are available in the file SOCKET.CH to identify an error condition.
Return

The function teturns .T. (true) if the socket is bound successfully, otherwise .F. (false) is returned.

Description

A socket is created without a name. Unless a name is bound to a socket, there is no way for other processes to reference it and, as a consequence, no data may be received on it. SocketBind() binds an unconnected stream or datagram socket to a name so that the local part of a socket association is defined.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.