soSend (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.08.00


The soSend function transmits data on a socket.

When the function returns success, this does not mean that the data is delivered and received by the recipient; only that the data was sent.

 

On a blocking socket, the function will not return until the data is sent.

With a non-blocking socket, if the data do not fit into the send buffer, the function will return -4.

 

For a connection-based socket (type _SO_TYPE_STREAM), the socket must first be connected by the soConnect or soAccept functions before this function can be called.

For a connectionless socket (type _SO_TYPE_DGRAM), the destination given by the address parameter. The address parameter can be ignored if the soConnect function is used to set the destination.

Also, for a connectionless socket, care must be taken to not exceed the maximum packet size of the underlying protocol. If the data is too large to pass through atomically, no data is is sent and an error is returned.

 

 

Input:

socket : SYSHANDLE

Handle to the socket.

 

data : PTR

Address of the buffer that contains the data to be sent.

 

size : DINT

Number of bytes to send from the buffer.

 

address : STRING

The destination address. The address is ignored if a connection is established.

 

 

Output:

sent : DINT

The number of bytes sent.

 

 

Returns: INT

1

- Success.

0

- The function is not supported.

-1

- The handle is not a valid socket.

-2

- One or more parameters are illegal.

-3

- The socket is closed.

-4

- The socket is marked non-blocking and the operation would block.

-6

- The socket require a connection and is not connected.

-7

- The socket already have a connection.

-11

- Memory error.

-12

- The action requires an address.

-13

- The data size is too large.

-14

- One or more flags are invalid.

-17

- Generic error.

-110

- The secure transfer failed.

-111

- The secure connection is closed.

 

 

Declaration:

FUNCTION soSend : INT;
VAR_INPUT
  socket  : SYSHANDLE;
  data    : PTR;
  size    : DINT;
  address : STRING;
  sent    : ACCESS DINT;
END_VAR;

 

 


Example:

 

Please see the "Examples - Telnet server2"