I have a socket which is used to receive and also send packets. And the pseudo codes are:
setnonblock(fd);
add_event(event_base, recv_ev);
while("I have packets to write"){
send(fd, packet);
....
}
....
now the issue is, since fd is non-blocking, send(fd) many return before it finish sending packets. but I hope it can send the packet successfully before the program runs to the next step, or register an event for it. But if I register an event for it, the event may be triggered frequently even if there are no packets available (note the packets are not from recv() in the pseudo code ,but from somewhere else)
The whole point of using non-blocking sockets is allow you to do stuff while the packet is being sent. If you have nothing to do between sends, you may as well use blocking sockets.