WIZnet Developer Forum

sent RST after got FIN

・What am I doing:
A TCP server and A UDP “server” simultaneously

・What I have done in my code:
when I want to close the TCP socket or got a FIN
if the socket status is SOCK_ESTABLISHED then
DICONN
otherwise
CLOSE

・What happend:
got FIN
sent ACK
sent RST

・Then I changed my code as this:
when I want to close the TCP socket or got FIN
if the socket status is SOCK_LISTEN then
CLOSE
if the socket status is SOCK_ESTABLISHED or SOCK_CLOSE_WAIT then
DICONN

・What happend then:
got FIN
sent ACK, FIN
got ACK
sent RST

What am I asking:
What shold I do when I want to close the TCP socket or got a FIN?
For some reason I can not reconstruct the code.
Only this one function I can touch.

・Further question:
①Are these the all status that available in TCP server?
SOCK_INIT
SOCK_LISTEN
SOCK_ESTABLISHED
SOCK_CLOSE_WAIT
SOCK_SYNSENT
SOCK_SYNRECV
SOCK_FIN_WAIT
SOCK_FIN_WAIT
SOCK_CLOSING
SOCK_TIME_WAIT
SOCK_LAST_ACK
SOCK_ARP_0
SOCK_ARP_1
SOCK_ARP_2
②Is the SOCK_CLOSE_WAIT the only available status when got a FIN?
③When I want to close the TCP socket, what should I do when the the CHIP is in each status in ①?

④Are these the all status that available in UDP “server”?
SOCK_INIT
SOCK_UDP
SOCK_ARP_0
SOCK_ARP_1
SOCK_ARP_2
⑤When I want to close the UDP socket, what should I do when the the CHIP is in each status in ④?

Thank you.

  1. The status to be managed while using the tcp server is as follows.
    This is because the rest of the status is a brief moment or does not occur on the TCP server.

  2. Yes, when FIN is received, W5100 becomes SOCK_CLOSE_WAIT state.

  3. Transmit DISCONNECT or CLOSE Command.
    CLOSE is recommended for INIT and LISTEN, CLOSE or DISCONNECT for ESTABLISHED, and DISCONNECT for CLOSE_WAIT.

  4. Like the tcp server, the status to be managed while using the udp is as follows.

  5. Please send a close command

Thank you for your reply.

Is that possible I get these “brief moment” status when I read Sn_SR, or they are hide from users?

That is possible.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.