soRecv (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

All

Firmware version:

1.08.00


The soRecv function receives data from a socket.

The function return any data available, up to the requested amount, rather than waiting for receipt of the full amount requested.

 

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

With a non-blocking socket, if no data is available, 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 socket must be bound to a local address with the soBind function before this function can be called.

 

 

Input:

socket : SYSHANDLE

Handle to the socket.

 

data : PTR

Address of the buffer that contains the received data.

 

maxsize : DINT

Maximum number of bytes that can be received (size of "data").

 

 

Output:

size : DINT

The number of bytes received.

 

 

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.

-11

- Memory error.

-17

- Generic error.

-110

- The secure transfer failed.

-111

- The secure connection is closed.

 

 

Declaration:

FUNCTION soRecv : INT;
VAR_INPUT
  socket  : SYSHANDLE;
  data    : PTR;
  maxsize : DINT;
  size    : ACCESS DINT;
END_VAR;

 

 


Example:

 

Please see the "Examples - Telnet server2"