|
Technical Support Support Resources Product Information | RL-ARM: GENERAL TCP/IP QUESTIONS
Information in this article applies to:
I have started to use the TCP/IP stack of the Real-Time Library and in this context I have the following questions: QUESTION- Do I need to close/abort a TCP/IP socket when the event TCP_STATE_CLOSED is detected?
- Can I change from client to server mode after the TCP_STATE_CLOSED event is received or do I need to call the function tcp_abort?
- What is the effect when I use the call tcp_close on a TCP socket that is currently not open? Calling tcp_close does not seem to generate close event?
- When my server application is closed TCPnet appears to send sync packets every second. What can be the reason for that?
ANSWER- The event TCP_EVT_CLOSE is detected when a TCP socket is closed. There is no further action required in your code. However you must wait until the TCP socket is really down before starting a new connection. TCPnet exchanges close packets after the event TCP_EVT_CLOSE is detected and before TCP socket is in idle state (which is reported by the events TCP_STATE_CLOSED or TCP_STATE_LISTEN. You should use the function tcp_get_state() to check the status of the TCP socket.
- There is no need to call the function tcp_abort, to close a TCP socket, but you must wait until the TCP socket is in the state TCP_STATE_CLOSED or TCP_STATE_LISTEN.
- A call to the function tcp_close() sends a control packet with flag TCP_FLAG_FIN set. When this packet is acknowledged by the remote peer a socket is considered as closed. TCPnet waits for the acknowledgement from the remote peer and again you should wait until the socket is in the state TCP_STATE_CLOSED or TCP_STATE_LISTEN.
- When the function tcp_connect() is called, TCPnet starts to send sync packets. When these sync packets are not answered after a number of retries, the TCP/IP connection is reset and the event TCP_EVT_ABORT is generated.
Last Reviewed: Tuesday, January 23, 2007
|
|