Function SocketCreate() Professional

Creates a new socket and binds it to a given port.

Syntax
SocketCreate( [<nSocketType>]  , ;
              <nPort>          , ;
              [<cLocalAddress>], ;
              [<lReuseAddress>], ;
              [@<nError>]        ) --> nSocket
Parameters
<nSocketType>
Constants from the file SOCKET.CH must be used for this parameter:
Type of socket to create
Constant Description
SOCK_STREAM *) TCP stream socket
SOCK_DGRAM UDP datagram socket
  1. default
<nPort>
This is the numeric port number on the local computer to bind the socket to. When the numeric value 0 is passed in the parameter <nPort>, the socket is bound to a port from the dynamic port range. In this case, the number of the bound port can be retrieved using the function SocketGetSockName().
<cLocalAddress>
The local address is specified with a character string containing the host name or its IP address in dotted octet notation. If the application does not care what address is assigned to the socket, it may not provide this parameter. In this case the #define constant INADDR_ANY is used for <cLocalAddress>.
<lReuseAddress>
The default value for this parameter is .F. (false). When it is set to .T. (true) the socket may reuse the local address if it is already used by another socket.
<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 returns a numeric socket descriptor on success. If a socket cannot be created, the value of the #define constant INVALID_SOCKET is returned.

Description

This function is used on the server side of a communication channel. It creates a socket and binds it to the specified address and port, which is equivalent to calling SocketNew() and SocketBind(). The bound socket is then used to listen to or to accept incoming communication requests.

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.