What happens when a connection drops in sockets (C)

Okay, so this seems like a pretty straightforward problem, but I feel like I read every article on socket programming that I can find and didn't find a satisfactory answer. Let me first describe the system I am programming. I'm sorry, but I have to be very vague for NDA purposes, but that will be enough to ask me a question.

I am writing a central multithreaded C server with a thread pool. There are two types of customers: Type A and Type B. There are several thousand each. Type A is workers who do things for type B. Type A constantly updates information about itself on the server (say, every 15 seconds). Type B only talks to the server when it needs something, and at that moment the server selects client A and assigns it a task. It is about 24/7 and very time sensitive.

I decided to go with a permanent TCP model - this means that as soon as B asks for work, the server can immediately send information to A, without waiting for question A to connect to the server. In addition, if each A talks to the server every 15 seconds, there will be a lot of overhead to maintain connections.

If the server A selected by server is unavailable, it needs to select the new A as soon as possible, since B is very impatient.

My question is, how can I tell if the connection was deleted? I'm not talking about closing a socket, but just not plugged in. For example, B1 wants to do the job, the server selects A1 and sends a request. However, someone decides to disconnect the Ethernet cable. I cannot allow the server to happily send data to A1 until the connection time ends in a few minutes. Can I ping a client before trying to send it or something else? Will it introduce too much latency? What can be done?

+3
source share
1 answer

, - . , , . , , , , ​​ .

, . , , . ( , MPLS-TE, ), , .

.

+4

Source: https://habr.com/ru/post/1794618/


All Articles