Settings for C # keepalive

Source: Internet
Author: User

Related Settings for C # keepalive

Online has a lot of relevant keepalive content, finally found about C # in this aspect of information, set up under, there is reliable!

TcpListener MyListener = new TcpListener (Ipaddress.any, port);//Binding port IP Information  mylistener.start ();//Start listening TcpClient Newclient=mylistener.accepttcpclient ();//Accept Request NewClient.Client.IOControl (Iocontrolcode.keepalivevalues, KeepAlive (1, 30000, 10000), NULL);//Set keep-alive parameter private byte[] KeepAlive (int onOff, int keepalivetime, int Keepalivein Terval) {     byte[] buffer = new BYTE[12];     Bitconverter.getbytes (ONOFF). CopyTo (buffer, 0);     Bitconverter.getbytes (KeepAliveTime). CopyTo (buffer, 4);     Bitconverter.getbytes (KeepAliveInterval). CopyTo (buffer, 8);     return buffer;  }

KeepAlive函数参数说明:

onOff:是否开启KeepAlive

keepAliveTime:开始首次KeepAlive探测前的TCP空闭时间

keepAliveInterval: 两次KeepAlive探测间的时间间隔

Keep-alive location I put it on. Once the client is received, it is set once for each client that is connected.

Related article: http://www.cnblogs.com/lidabo/p/4253356.html

Settings for C # keepalive

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.