WsCreate Procedure

Creates a socket that is bound to a specific protocol.

Syntax

[ 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)

Where

enumAWSProtocol can be one of the following:

 

Name

Value

Description

aWsTcpIp

1 *

The TCP/IP protocol

aWsUDP

2

The UDP protocol

Comments

The WsCreate function causes a socket descriptor and any related resources to be allocated and bound to a specific transport service provider. 

Example

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) 

See Also

Using Winsock Procedures, WsAccept, WsClose, WsConnect