mtcp-stack / mtcp

mTCP: A Highly Scalable User-level TCP Stack for Multicore Systems
Other
1.98k stars 435 forks source link

Sending messages in burst using mtcp_write #276

Open wasiqnoorahmad opened 4 years ago

wasiqnoorahmad commented 4 years ago

Hello,

I am trying to write an application with mTCP which repeatedly sends multiple requests to the server without waiting for a response. In short, we are not following the request response model directly. However, I have observed that I am only able to send as much packets as specified by the RECV_BUFF variable. For example, if RECV_BUFF was set 2048 and my single request's size is 1024, then I am only able to send two packets. After that mtcp_write throws an EAGAIN error. According to mtcp_write link documentation, EAGAIN means that I need to send the message again until buffer is available. Which in my case means I have to repeatedly call mtcp_write until it succeeds which in essence means wasted CPU cycles.

Can you please guide what will be the best way to achieve what I need with mTCP? Is there a way to "flush" the packets without waiting for the buffer?

Regards

ajamshed commented 4 years ago

Please use MTCP_EPOLLOUT in mtcp_epoll_ctl() to check when the socket descriptor is ready for more write operations. Please see epserver.c example on how to use the API.