mono, c#, sockets, performance

依然范特西╮ 提交于 2020-01-01 14:18:45

问题


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).


回答1:


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.



来源:https://stackoverflow.com/questions/1783660/mono-c-sockets-performance

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!