Creates a socket that is bound to a specific protocol.
[ ASocket = ] WsCreate ( [enProtocol] [,lFlags] )
The WsCreate procedure syntax has the following parts:
Name |
Type |
Description |
ASocket |
Val ASocket |
If no error occurs, WsCreate returns a descriptor referencing the new socket. Otherwise, a value of -1 is returned |
enProtocol |
Val enumAWsProtocol |
The protocol for the connection. |
lFlags |
Val Long |
Optional. The socket creation flag. Passing 0 will create Ipv4 socket, passing 4 will cause the socket to be created for IPv6 address. (ATEasy 2024) |
enumAWSProtocol can be one of the following:
Name |
Value |
Description |
aWsTcpIp |
1 * |
The TCP/IP protocol |
aWsUDP |
2 |
The UDP protocol |
The WsCreate function causes a socket descriptor and any related resources to be allocated and bound to a specific transport service provider.
The following example creates a socket that is bound to the IPv4 address and TCP/IP protocol:
! Open a socket:
socket1=WsCreate(aWsTcpIp, 0)
! Associate a local host with a socket at a local port:
WsBind(socket1, lPort, lHost)
! Set the Socket to listen for an incoming connection from a client:
WsListen(socket1)
! Attempts to return a read/write socket to the remote client in twenty seconds:
Socket2=WsAccept(socket1, 20000)