• Welcome to Valhalla Legends Archive.
 

select(), sockets, and writefds...

Started by iago, January 06, 2006, 12:21 PM

Previous topic - Next topic

iago

I was wondering if it's ever possible for sockets to block writing.  When implement select(), waiting to send packets is really annoying, since I don't normally wait on writefds, I have to adds it to a queue, set a flag, wake up the select() call, and tell it to wait for writing.  Is this necessary for sockets? Or is that only designed for other select() uses?

Thanks
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

Yes, sockets will block on send() if the underlying send buffer is filled and the socket is operating in blocking mode.  As far as I know, there is no standard way to make sockets block on send and not recv.

If you are targetting Win32, I strongly recommend that you use overlapped I/O instead of conventional, BSD-compatible socket APIs.

iago

I'm targetting Linux, actually, so I'm using the BSD interface. 

Thanks for the response, though, I'll find a way to implement it properly!
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Skywing

Quote from: iago on January 06, 2006, 01:02 PM
I'm targetting Linux, actually, so I'm using the BSD interface. 

Thanks for the response, though, I'll find a way to implement it properly!


I would recommend just building a queue of send requests and then transferring as much of them as you can at once with an iovec send when writing is reenabled on the socket.