slowbro/phpircd

On non blocking sockets, you cannot assume a socket is ready for socket_write

Closed this issue · 1 comments

On all of the writes, socket_write is immediately called, but when using non blocking sockets this is an invalid approach.

On non-super-slow connections, it will likely never be an issue, but technically sockets should only be written to when they've been signified as being ready to be written to.

Basically, your select loop needs to check for write-ready sockets and write out of their buffers to the socket instead of immediately calling socket_write.

An alternate option would be to check the return of socket_write to make sure the written length == the length of the data. This option would be blocking though since it would require a CPU-eating loop to make sure it was all written (if it took more than a few iterations).

Resolved in 6483d69. Thanks!