单声道,C#,插座,性能 [英] mono, c#, sockets, performance

查看:190
本文介绍了单声道,C#,插座,性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发侦听Unix套接字和同步客户端发送一些小的数据块简单的异步服务器。当我从客户端发送数据时服务器接收它们的时刻的时刻之间的时间是完全地随机的,从1到9秒。我不知道为什么原因呢?服务器如图MSDN这里的例子(使用beginReceive)来实现:的http:// MSDN .microsoft.com / EN-US /库/ fx6588te.aspx

 端点EP =新UnixEndPoint(_filename) ; 
_socket =新的Socket(AddressFamily.Unix,SocketType.Stream,ProtocolType.IP);


{
_socket.Bind(EP);
_socket.Listen(_maxConnectionsInQuee);

,而(真)
{
done.Reset();
_socket.BeginAccept(新的AsyncCallback(AcceptCallback),NULL);
done.WaitOne();
}
}

和客户端:

 端点EP =新UnixEndPoint(_filename); 
_socket =新的Socket(AddressFamily.Unix,SocketType.Stream,ProtocolType.IP);
_socket.Connect(EP);
字节[]字节= Encoding.UTF8.GetBytes(消息);
_socket.Send(字节);



方法将数据发送到所述服务器从web服务方法调用(经由xsp2运行)。

解决方案

据occures,在单Unix套接字都OK了:)。我这是完全无关的Mono.Unix和UNIX域套接字某些线程问题。感谢所有您的帮助。


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

解决方案

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.

这篇关于单声道,C#,插座,性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆