WsSend Procedure

Writes bytes to the specified socket and returns the number of bytes sent.

Syntax

[ lReturn = ] WsSend ( socket, lTimeout [, enMode ], pSrc [, lBytes] [, lRemotePort] [, vRemoteHost] [, sEos] )

The WsSend procedure syntax has the following parts:

 

Name

Type

Description

lReturn

Long

If no error occurs, send returns the total number of bytes sent. Otherwise, -1 is returned if failed, -2 if timeout

socket

Val ASocket

A descriptor identifying a (possibly connected) socket

lTimeout

Val Long

The maximum length of time in milliseconds attempting to send the data.

enMode

Val enumAIoMode

Output send mode.Only the default value 0 (aioDefault)  can be combined with aioDisableBstrConvert.

pSrc

Val Any

The source buffer for the bytes to send.

lBytes

Val Long

Maximum number of data bytes to send. When the default value (-1) is used the size of the send buffer pSrc is used.

lRemotePort

Val Long

The port from which to receive the data. The default is -1.

vRemoteHost

Val Variant

The host address of the port. The default is -1. Use Long integer ((vtI4) for IPv4 and in ATEasy 2024 (v13) array of 16 bytes (vtUI1or vtArray)  for IPv6;

sEos (v 6.0)

Val BString

The EOS is appended to the output data. The default is an empty string.

Where

enumAIoMode can have one of the following values:

 

Name

Value

Description

aioDefault

0

Receive data available

aioWaitGpibSrqVxiDor

1

Receive on Srq (gpib) or on Dor (vxi)

aioGpibImmediateOrSrq

2

Receive on Immediate or Srq (gpib)

aioDisableBstrConvert

4

Disable conversion of BString to String

aioDisableComReceiveEarlyReturn (v 6.0)

8

Disable early return from ComReceive

aioDisableWsReceiveEarlyReturn (v.6.0)

0x10

Disable early return from WsReceive

Comments

Sends data to a remote host using the WsSend function.

If the EOS is not empty, then the EOS will be appended to the output data (v 6.0).

The usage of the WsSend function is slightly different when using the TCP protocol than when using the UDP protocol.

TCP:

When using a TCP connection-oriented stream, once client and server sockets are connected, you can use the WsSend and WsReceive functions to exchange data. Omit the lRemotePort and vRemoteHost parameters for the functions.

The WsSend function writes outgoing data on a connected socket. The WsReceive function reads incoming data on connection-oriented sockets. 

UDP:

The UDP datagram socket application calls WsReceive with the lRemotePort and vRemoteHost parameters to prepare to receive data from a remote host. The WsReceive function reads incoming data on unconnected sockets and captures the address from which the data was sent. To do this, the local address of the socket must be known.

The WsSend function is used on a connectionless socket to send a datagram to a specific peer socket identified by the lRemotePort and lRemoteHost parameters.

Note: Successfully completing a WsSend function call does not confirm data was successfully delivered in a connectionless socket.

Example

The following two examples will send a string to a remote host in both the TCP and UDP protocol modes.

UDP Protocol:

WsSend(lSocket, 300, , "SWITCH ON", , lRemotePort, lRemoteHost)

TCP Protocol:

WsSend(socket,300, ,"SWITCH ON")

See Also

WsAccept, WsListen, WsReceive