Commands and functions
P.
238 of 349
TCP server and client
Server and client
TCP ports
Connecttcp
Closetcp
The Enertex® EibPC functions both as a server and as a client. Every 100 ms, it responds to a new
connection request. If the Enertex® EibPC is connected, it answer the requests with the cycle time of
the processing cycle.
The TCP/IP server of the Enertex
®
EibPC receives connection requests always via its port 4809.
Definition
●
Function
connecttcp
(
port, ip
)
Arguments
●
Argument
port
of data type u16
●
Argument
ip
of data type u32 (the destination's address in the usual notation, e.g.
192.168.22.100)
Effect
●
The Enertex® EibPC functions as a client. It establishes a connection to the given
destination (defined by
ip
address and
port
).
●
The function returns its processing status:
- successful = 0
- in progress = 1
- error= 2
- error due to an already existing connection = 3
- error caused by too many active connections = 4
- connection automatically closed due to a timeout (not responding) = 6
- connection closed by user with
closetcp
= 7
- TCP counterpart closed the connection = 8
- Initial value = 9
●
After 30 seconds of inactivity of an existing connection, the Enertex® EibPC disconnects
automatically
Data type result (Return)
●
u08 (The return value goes asynchronous to the main development loop - see p. 124)
Definition
●
Function
closetcp
(
port, ip
)
Arguments
●
Argument
port
of data type u16
●
Argument
ip
of data type u32 (the destination's address in the usual notation, e.g.
192.168.22.100)
Effect
●
The Enertex® EibPC closes the connection to the given destination (defined by
ip
address
and
port
).
●
The function returns its processing status:
- successful = 0,
- in progress = 1 and
- error = 2
- error, the connection does not exist = 5
Data type result (Return)
●
u08
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]