socket-cpp icon indicating copy to clipboard operation
socket-cpp copied to clipboard

CTCPServer::Send can result in SIGPIPE

Open logidelic opened this issue 4 years ago • 2 comments

First, thanks for this project. Quite useful.

One issue I've noticed so far: If the connection gets disconnected for some reason just before a CTCPServer::Send call, then Send will result in a SIGPIPE under Linux, aborting the program.

Instead, this should be handled gracefully (ex Send should return an error).

logidelic avatar Apr 07 '21 13:04 logidelic

Hello logidelic,

You're welcome.

Some insights to fix this issue : https://stackoverflow.com/questions/108183/how-to-prevent-sigpipes-or-handle-them-properly https://stackoverflow.com/questions/48229430/sigpipe-in-c-determining-which-tcp-socket-is-disconnected

embeddedmz avatar Apr 21 '21 13:04 embeddedmz

Thanks for that. Yea, for the send call, I ended up changing the flags passed to MSG_NOSIGNAL (I think recv needs the same). IMO this be the default for this lib, but I'll let you decide. :)

logidelic avatar Apr 21 '21 13:04 logidelic