Home > Back-end >  Excuse me method to detect break line reconnection Windows socket client (if it does not create a th
Excuse me method to detect break line reconnection Windows socket client (if it does not create a th

Time:10-25

C/C + + Windows socket client detection methods of break line reconnection should have several main:
1. Use their own keep alive
This method can the client through what way to get the timing of the bolt or event?

2. The recv returns a value judgment
This method can identify the situation will be limited

3. Implement a heartbeat
This approach generally want to create a thread to special timing sending heartbeat package, if not create a thread, can use this way, please?
If you have to create a thread, try not to choose this method (plan)


CodePudding user response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,

CodePudding user response:

reference 1st floor gouyanfen response:
right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

CodePudding user response:

refer to the second floor scitachi response:
Quote: refer to 1st floor gouyanfen response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

Heartbeat server timing to send, you don't have to be always receive, receive feedback, processing, by the way, don't need a single thread

CodePudding user response:

reference gouyanfen reply: 3/f
Quote: refer to the second floor scitachi response:

Quote: refer to 1st floor gouyanfen response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

Heartbeat server timing to send, you don't have to be always receive, receive feedback, it is ok to processing, by the way, don't need a single thread open


Use a heart rate monitor to when disconnected, the client automatically trigger reconnection, then continue to transmit data,
Keepalive as heartbeat timeout will automatically clear off some resources, is unable to control it reconnection?
Besides the above said when the client receive feedback by the processing of heartbeat packets, this is also need a timeout timer judgment? Can't thread line

CodePudding user response:

reference 4 floor scitachi response:
Quote: reference gouyanfen reply: 3/f

Quote: refer to the second floor scitachi response:

Quote: refer to 1st floor gouyanfen response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

Heartbeat server timing to send, you don't have to be always receive, receive feedback, it is ok to processing, by the way, don't need a single thread open


Use a heart rate monitor to when disconnected, the client automatically trigger reconnection, then continue to transmit data,
Keepalive as heartbeat timeout will automatically clear off some resources, is unable to control it reconnection?
Besides the above said when the client receive feedback by the processing of heartbeat packets, this is also need a timeout timer judgment? Can't thread line

Without the timer, the socket send messages, you don't have to receive immediately, without receiving will be in the cache, when you need to receive messages, to decompose the received message, is the heart of skip, not heartbeat is feedback, you need to assume that the server ten seconds to send a heartbeat, you didn't receive feedback, also did not received in ten seconds a heartbeat, on behalf of the bolt, you recv see is synchronous or asynchronous processing, it is ok to do the processing according to the circumstance,

CodePudding user response:

reference 5 floor gouyanfen reply:
Quote: refer to 4th floor scitachi response:

Quote: refer to the third floor gouyanfen response:

Quote: refer to the second floor scitachi response:

Quote: refer to 1st floor gouyanfen response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

Heartbeat server timing to send, you don't have to be always receive, receive feedback, it is ok to processing, by the way, don't need a single thread open


Use a heart rate monitor to when disconnected, the client automatically trigger reconnection, then continue to transmit data,
Keepalive as heartbeat timeout will automatically clear off some resources, is unable to control it reconnection?
Besides the above said when the client receive feedback by the processing of heartbeat packets, this is also need a timeout timer judgment? Can't thread line

Without the timer, the socket send messages, you don't have to receive immediately, without receiving will be in the cache, when you need to receive messages, to decompose the received message, is the heart of skip, not heartbeat is feedback, you need to assume that the server ten seconds to send a heartbeat, you didn't receive feedback, also did not received in ten seconds a heartbeat, on behalf of the bolt, you recv see is synchronous or asynchronous processing, it is ok to do the processing according to the circumstance,



This is because want to guarantee the reliability of the data, is want to send a data, recv once, if the feedback under normal to send a, or to resend,
Heart to deal with the middle found that bolt and retransmission, according to what you say, these should be dealt with, together
So with commonly used method is different from the design,,,

CodePudding user response:

refer to 6th floor scitachi response:
Quote: refer to the fifth floor gouyanfen reply:

Quote: refer to 4th floor scitachi response:

Quote: refer to the third floor gouyanfen response:

Quote: refer to the second floor scitachi response:

Quote: refer to 1st floor gouyanfen response:

The right is good, the client you have requirements as far as possible need not thread, the server without this requirement, can be implemented on the server one-way heartbeat, the client receives the message, is already more than a heartbeat time break line, unified handling heartbeat again when the client receives the message again and data, so that you can not create a thread,


The client need to send data, the service side and recv server-side feedback, adopt corresponding way, according to the feedback send have a particular thread,
In this thread should be not appropriate also receives a heartbeat packet?

Heartbeat server timing to send, you don't have to be always receive, receive feedback, it is ok to processing, by the way, don't need a single thread open


Use a heart rate monitor to when disconnected, the client automatically trigger reconnection, then continue to transmit data,
nullnullnullnullnullnullnullnullnull
  • Related