Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Networking (https://www.askmehelpdesk.com/forumdisplay.php?f=76)
-   -   Where can I find helpful information about expiring sockets in C (https://www.askmehelpdesk.com/showthread.php?t=559631)

  • Mar 4, 2011, 12:45 PM
    BenAssa
    Where can I find helpful information about expiring sockets in C
    I want to make a server that accepts socket connections, but expires the connection if no information is sent.
    For this I need to either use non blocking read/select cycles or some method to expire connections
    Does anyone know where can I find more information about how to do this
  • Mar 5, 2011, 07:03 PM
    cajalat
    I'm not a C developer (well I haven't programmed in C in ages) but since you posted this to the networking section perhaps an analogy from network switches/routers can help you figure it out.

    On a network switch/router there is a similar issue with aging out ARP and CAM entries. ARP and CAM entries expire after a certain amount of time has passed and are removed from the router or switch database. They track the time passed in terms of a count down timer from the last seen packet. Whenever a packet is seen coming from a switch port the CAM entry aging timer reset. Whenever an ARP is performed on the network the ARP entry for a particular IP/MAC pair is also reset.

    Perhaps you can reset a count down timer every time you see traffic through the connection and when the timer reaches 0 you close the socket connection by issuing a FIN to both ends of the client/server connection.

  • All times are GMT -7. The time now is 11:06 PM.