FB_SocketSend

FB_SocketSend 1:

Using the function block FB_SocketSend, data can be sent to a remote client or remote server via the TwinCAT TCP/IP Connection Server. A remote client connection will first have to be established via the function block FB_SocketAccept, or a remote server connection via the function block FB_SocketConnect.

VAR_INPUT

VAR_INPUT
    sSrvNetId   : T_AmsNetId := '';    
    hSocket     : T_HSOCKET;      
    cbLen       : UDINT;            
    pSrc        : DWORD;            
    bExecute    : BOOL;         
    tTimeout    : TIME := T#5s;     
END_VAR

sSrvNetId: string containing the network address of the TwinCAT TCP/IP Connection Server. For the local computer (default) an empty string may be specified.

hSocket: connection handle of the communication partner to which data are to be sent.

cbLen: number of data to be sent in bytes.

pSrc: address (pointer) of the transmit buffer.

bExecute: the function block is enabled via a positive edge at this input.

tTimeout: maximum time that may not be exceeded when the function block is executed.

FB_SocketSend 2:

If the transmit buffer of the socket is full, for example because the remote communication partner does not receive the transmitted data quickly enough or large quantities of data are transmitted, the function block FB_SocketSend will return ADS timeout error 1861 after the tTimeout time. In this case, the value of the tTimeout input variable must be increased accordingly.

VAR_OUTPUT

VAR_OUTPUT
    bBusy       : BOOL;
    bError      : BOOL;
    nErrId      : UDINT;
END_VAR

bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.

bError: If an error should occur during the transfer of the command, then this output is set once the bBusy output was reset.

nErrId : If the bError output is set, this parameter returns the TwinCAT TCP/IP Connection Server error number.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT version 2.8.0 or higher

PC or CX (x86)

TcpIp.Lib

( Standard.Lib; TcBase.Lib; TcSystem.Lib are included automatically )

TwinCAT v2.10.0 Build >= 1301

CX (ARM)