开发者

socket blocking between two processes in C on unix

开发者 https://www.devze.com 2023-02-02 16:32 出处:网络
Appreciate if anyone can help me to get a better solution... In my application, there is a TCP client(C) and other TCP server(S) on linux machine.

Appreciate if anyone can help me to get a better solution...

In my application, there is a TCP client(C) and other TCP server(S) on linux machine.

On production envoronment, on high load this server sometimes stop receiving request from Client and hence creating bottlenecks for client as client side is a blocking socket.To recreate the problem locally .. i put a load and take the server on GDB and this way the problem is recreated.

Can anyone suggest some other mechanism to block 开发者_C百科the socket wihout disturbing the process ?


What exactly would you like to hear? If the server is busy, that is, other processes are being serviced because they too do get a share of the timeslices by the scheduler, there is not much you can do except raising your program's priority/timeslice length, or lowering theirs.

Note that TCP implementations generally use a socket buffer so that some transfers can continue to happen while a process is currently busy dealing with data, or while waiting for the next timeslice.

Do you have some code to show?


Can anyone suggest some other mechanism to block the socket wihout

disturbing the process ?

Do the connection in a separate thread so that you do not block the whole process


I didn't really get the point, but I guess you have implement a blocked tcp server. If this is true, then there may be some methods to solve it

  1. Use multithreading or event-driven architecture to improve I/O efficiency.
  2. Extract I/O methods code from the others
  3. Multiprocessing may be required to avoid system limits, such as the count of open files.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号