Instructions
259 C-Control Pro IDE
© 2013 Conrad Electronic
ton to initiate a complete system reboot.
5.11.2 TCP/IP Programming
Open a TCP/IP connection:
Create a receive buffer with ETH_SetConnBuf.
The call of ETH_ConnectTCP establishes a connection and sets the internal state to
ES_CONNECTING.
With periodical calling of ETH_GetStateTCP the connection state is monitored. After
ES_CONNECTING the state can change to ES_CONNECTED or ES_DISCONNECTED. At
ES_CONNECTED, the connection is open, else there might be a timout or the opposite side has
declined.
After the connection is open, it is possible to send data with ETH_SendTCP.
Simultaneously check periodically with ETH_CheckReceiveBuf if data has been received, and
monitor with ETH_GetStateTCP if the connection goes to the state ES_DISCONNECTED some-
time.
A call to ETH_DisconnectTCP terminates the connection.
Wait on a TCP/IP port for an incoming connection:
Create a receive buffer with ETH_SetConnBuf.
ETH_ListenTCP monitors a specified port.
Check periodically ETH_CheckReceiveBuf to see if data has been received and therefore a new
connection has been opened from the outside. The state of ETH_GetStateTCP now has the value
ES_LCONNECTED.
After the connection is open, it is possible to send data with ETH_SendTCP.
Monitor periodically ETH_GetStateTCP to check if the connection gets terminated (state
ES_DISCONNECTED).
A call to ETH_DisconnectTCP terminates the connection.
It is recommended to look at the demo programs for UDP and TCP/IP.
The TCP/IP configuration allows up to 10 simultaneously TCP/IP connections to be opened, and
be listened to up to 3 ports for incoming connections.
For default 4kb are reserved for the TCP/IP stack. Depending on the use the stack needs more
RAM or less. The memory needed is difficult to calculate, and should be determined by tests.
Examples
The program will connect to the HTTP port, sends a "GET" command and receives the response: