dermesser / libsocket

The ultimate socket library for C and C++, supporting TCP, UDP and Unix sockets (DGRAM and STREAM) on Linux, FreeBSD, Solaris. See also my uvco library for a refreshed version!
https://borgac.net/~lbo/doc/libsocket/
Other
797 stars 195 forks source link

Unix Stream Socket Server #46

Closed mitsus closed 7 years ago

mitsus commented 7 years ago

Hi, firstly compliments for your library. Now i use your library into a thread of my C++ program. I've a question. This is my piece of code (server thread):

while (1){ memset(shared_in,0,3000); try { unix_stream_server srv(bindpath); unique_ptr<unix_stream_client> client; client = srv.accept2(); client->rcv(shared_in,3000); *client << shared_out; }catch (const libsocket::socket_exception& exc){ std::cerr << exc.mesg; } }

If i connect a client, but it for a problem close the connection before receiving the response from the server, my program exit (from all threads) when i call

*client << shared_out;

...where shared_out is a variable with the value passed from the second thread. How can i solve?

Thanks a lot and Regards

dermesser commented 7 years ago

I don't see an issue with the library itself, can you please provide a more detailed example with exceptions/errors?