WIZnet Developer Forum

Sample code needed for TCP timeout and keep alive

Hi all,

I am new to wiznet w5100 and I have done with TCP/IP based Client/server using interrupt.
Now I want to use SEND_KEEP and TIMEOUT for TCP/IP client/server link status. please help me I don’t know how to implement it.
if anybody have sample code then please provide me…

thank you all…

Hi,

for example.

switch(getSn_SR(sn))
{
 //...
 case SOCK_ESTABLISHED:
     // check to send keep time
     if(is_send_keep_time_elapsed) setSn_CR(sn,Sn_CR_SENDKEEP);
     break;
 case SOCK_CLOSED:
     // if TIMOUT . socket should be closed.
      if(getSn_IR(sn) & Sn_IR_TIMEOUT) printf("TIMEOUT");
     // ...
    break;
 //....
}

You can just perform SENDKEEP command with Sn_CR register and check the socket closed & Sn_IR regisiter.

Thank you.

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