You are on page 1of 3

_ETN004_SOCKET_TcpSend (1/3

)

ETN
-004 Send via TCP Socket: _ETN004_SOCKET_TcpSend
Basic Issues a request to the specified Ethernet Unit to send using a TCP socket.
function
Symbol Start trigger
_ETN004_SOCKET_TcpSend
↑ (BOOL) (BOOL)
EN ENO
Busy Flag (INT) (BOOL) Busy Flag
Unit No. UnitNo BUSY
(INT) (BOOL) Normal end
TCP socket No. TCPSocketNo OK
(INT) (BOOL) Error end
No. of bytes to send SendBytes NG
(WORD) (WORD) Communications error code
Send data storage area type SendAreaID CmndErrorCode (May be omitted.)
(INT) (WORD) TCP error code
Send data first storage word address SendAreaNo TcpErrorCode (May be omitted.)
(INT) No. of bytes sent
Result (May be omitted.)

File name Lib\FBL\omronlib\PLC\ETN\_ETN004_SOCKET_TcpSend10.cxf
Applicable Ethernet Unit CS1W-ETN21 and CJ1W-ETN21
models CPU Unit CS1*-CPU**H Unit version 3.0 or higher
CJ1*-CPU**H Unit version 3.0 or higher
CJ1M-CPU** Unit version 3.0 or higher
CP1H
CX-Programmer Version 5.0 or higher
yConditions CPU Unit Settings
for usage PLC Setup: Shared Settings for Communications Instructions in FBs
• Communications Instruction Response Timeout Time (default: 2 s)
• Number of retries (default: 0)
Shared Resources
• Communications ports (internal logical ports)
Other
• Communications must be within one network and cannot cross to another network.
Function A command is sent to the Ethernet Unit specified by UnitNo. to request a send from the specified TCP
description socket.
If send processing is completed normally, the number of bytes that was sent will be stored.
If the request command processing produces an error, a completion code indicating the error will be output
to the Communications Error Code.
If the request command is processed normally but the TCP socket send processing produces an error, a
completion code indicating the error will be output to the TCP Error Code.
FB • The FB is processed over multiple cycles. The BUSY output variable can be used to check whether the
precautions FB is being processed.
• OK or NB will be turned ON for one cycle only after processing is completed. Use these flags to detect
the end of FB processing.
Timechart
Start Trigger ON
OFF
Busy Flag (BUSY) ON
OFF

Normal end (OK) ON
or Error end (NG) OFF
FB execution completed.
At normal end: Sending is completed.

EN input Connect EN to an OR between an upwardly differentiated condition for the start trigger and the BUSY
condition output from the FB.
Restrictions • Always use an upwardly differentiated condition for EN.
Input • If the input variables are out of range, the ENO Flag will turn OFF and the FB will not be processed.
variables
Output • This FB requires multiple cycles to process. Always connect an OR including the BUSY output variable
variables to the EN input variable to ensure that the FB is processed to completion (see Symbol).
• Do not turn the BUSY output variable ON or OFF outside the FB.
_ETN004_SOCKET_TcpSend (2/3)

Application When bit A turns ON, a TCP socket send request is issued.
example Bit C will turn ON when the send request has been completed.

Ethernet CPU Ethernet CPU Unit Unit No.: 0
Unit Unit Unit TCP socket No.: 1 (TCP connection already
established)
Send request No. of bytes to send: 100 bytes
Send data first storage address: D15000
Results first storage address: D16000
(TCP connection already
established)
IP address: 196.35.32.55
UDP port No.: 4096
Send Data Storage Format Results Storage Format
D15000 D16000 No. of bytes sent
D15001
D15002 Send data
D15003
D15004

Bit A
_ETN004_SOCKET_TcpSend
↑ (BOOL) (BOOL)
EN ENO
Bit B Unit No. (INT) (BOOL) Busy Flag
&0 UnitNo BUSY Bit B
TCP socket No. (INT) (BOOL) Normal end
&1 TCPSocketNo OK Bit C
No. of bytes to send (INT) (BOOL) Error end
&100 SendBytes NG Bit D
Send data storage area type (WORD) (WORD)
Communications error code
P_DM SendAreaID CmndErrorCode
Send data first storage word address (INT) (WORD)
TCP error code
&15000 SendAreaNo TcpErrorCode
(INT) No. of bytes sent
Result D16000

Bit C
Processing after UDP socket send

Related TCP/UDP Error Codes
manuals Ethernet Units Construction of Networks Operation Manual (W420)
7-3 Command/Response Reference
FINS Error Codes
Communications Commands Reference Manual (W342)
5-1-3 Error Codes
_ETN004_SOCKET_TcpSend (3/3) 

Variable Tables
Input Variables
Name Variable name Data type Default Range Description
EN EN BOOL 1 (ON): FB started.
0 (OFF): FB not started.
Unit No. UnitNo INT &0 &0 to &15 The unit number of the Ethernet Unit.
TCP socket No. TCPSocketNo INT &1 &1 to &8
No. of bytes to SendBytes INT &1 &1 to
send &1980
Send data storage SendAreaID WORD #0082 P_CIO (#00B0): CIO Area
area type P_WR (#00B1): Work Area
P_HR (#00B2): Holding Area
P_DM (#0082): DM Area
P_EM0 (#0050) to P_EMC (#005C):
EM Area bank 0 to C
Send data first SendAreaNo INT &0
storage word
address

Output Variables
Name Variable name Data type Range Description
ENO ENO BOOL 1 (ON): FB processed normally.
(May be omitted.) 0 (OFF): FB not processed or ended in an error.
Busy Flag BUSY BOOL Automatically turns OFF when processing is
completed.
Normal end OK BOOL Turns ON for one cycle when processing ends
normally.
Error end NG BOOL Turns ON for one cycle when processing ends in an
error.
Communications CmndErrorCode WORD Outputs the error code when execution ends in an
error code error in the communications command level. Refer to
(May be omitted.) the FINS Command Reference Manual (W227) for
details on the error codes.
TCP error code TcpErrorCode WORD Outputs the error code when the TCP socket
(May be omitted.) operation ends in an error. Refer to 7-3
Command/Response Reference in the Ethernet Units
Construction of Networks Operation Manual (W420)
for details on the error codes.
No. of bytes sent Result INT The number of bytes that were actually sent.
(May be omitted.)

Version History
Version Date Contents
1.00 2004.6. Original production

Note
This manual is a reference that explains the function block functions.
It does not explain the operational limitations of Units, components, or combinations of Units and components. Always read
and understand the Operation Manuals for the system’s Units and other components before using them.