Disable socket connection in VxWorks-Disconnect the network cable or time out and automatically disconnect

Source: Internet
Author: User

During this period, the socket connection cannot be detected and exited due to network disconnection or long connection time.

 

Technical Background: the target machine runs on vxworks, while the pc can connect to the target board through serial port and telnet. After the pc connects to vxworks through telnet, execute the shell program we have written, here we call this shell program CLI. Because the telnet client is already writable, microsoft's cmd-> telnet command is generally used, while the telnet server is encapsulated in vxworks by the system and only provides one hook interface function, hook our own function to handle telnet connection and exit. In this hook function, the system only gives socketfd, sessionid, and connection status. When the telnet window is closed, or run the exit command to exit, the system will give the connection status to the mounted function, and unplug the network cable. After some time, telnet will automatically exit, the system does not give the connection status to the hook function, so that the server resources cannot be released in time. Originally, the ioctl function provided a mechanism for sending keepalive packets to check whether the network is valid. However, it seems that this mechanism is not applicable to network disconnection. The specific processing method is to implement a timeout mechanism, if no data is exchanged for all connections within a fixed period of time, the server will disconnect the connection. If more connections detect data, the connection timeout value will be set to 0, if there is no data exchange, the connection is closed after the time is accumulated.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.