[Mono-list] BUG/FIX: send() parameters
Jaroslaw Kowalski
jarek@atm.com.pl
Fri, 26 Apr 2002 21:34:52 +0200 (CEST)
By tracing socket calls in "sockets.c" I've noticed that when attempting
to send() to a closed stream, send() raises a signal EPIPE (Broken pipe),
which when not handled causes the app to quit. MAN says that by OR-ring
send_flag with MSG_NOSIGNAL we could prevent the signal
from being raised.
I'm not an unix expert, but I'm wondering if adding MSG_NOSIGNAL to this
system call wouldn't solve the problem. Or, is raising the signal desired?
At the frist glance after making the fix, "mint" works by raising an
exception and "mono" quits with assertion failure. I don't know what may
be causing the problem.
Here's the code snippet that demonstrates the problem:
string s;
for (;;)
{
s = reader.ReadLine();
writer.WriteLine("You typed: {0}", s);
writer.Flush();
};
Where reader is StreamReader on a NetworkStream() and writer is a
StreamWriter on the same stream. When a client disconnects WriteLine()
the app quits with "Broken pipe".
I changed the following line:
----
ret=send(socket_handle->fd, msg, len, send_flags | MSG_NOSIGNAL);
----
What do you think about introducing this fix? What about recv() then?
Jarek