views:

383

answers:

2

Hi!

I developed simple async server that listens to unix socket and sync client that send the some small piece of data. Time between moment when i send data from client to the moment when server receives them is completly random, from 1 to 9 seconds. I wonder why is the reason? Server is implemented as shown in msdn example here (using beginReceive): http://msdn.microsoft.com/en-us/library/fx6588te.aspx

EndPoint ep = new UnixEndPoint(_fileName);
_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);

try
{
     _socket.Bind(ep);
     _socket.Listen(_maxConnectionsInQuee);

     while(true)
     {
         done.Reset();
         _socket.BeginAccept(new AsyncCallback(AcceptCallback), null);
         done.WaitOne();
     }
}

And in the client:

EndPoint ep = new UnixEndPoint(_fileName);
_socket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP);
_socket.Connect(ep);
byte[] bytes = Encoding.UTF8.GetBytes(message);
_socket.Send(bytes);

Method that sends data to the server is called from webservice method (running via xsp2).

A: 

Most likely this is due to the Nagle algorithm which delays sending data until a timeout, or a buffer is full. You can disable this by setting the NoDelay option.

Mystere Man
The question was edited to remove the reference to domain sockets.
Mystere Man
It shouldn't be. I am using unix domain sockets...
Adrian Serafin
+1  A: 

Hi!

It occures that unix sockets in mono are ok :). I had some threading issues which were completely unrelated to Mono.Unix and unix domain sockets. Thanks all for your help.

Adrian Serafin