Turns out there was no need to drain the socket before closing it at all.
IRC transfers were failing because purple_xfer was closing the connection from the sender's side
before the receiver read everything.
The solution was in two parts:
- Make purple_xfer close the connections automatically only when
there is no read/write function defined in the respective protocol.
- Make a read function for IRC DCC that handles a return value of 0
This should be tested with more protocols to see if the transfers finish correctly.
Revision 2 (+82 -44)