代码之家  ›  专栏  ›  技术社区  ›  Adrian Serafin

单声道,c#,插座,性能

  •  4
  • Adrian Serafin  · 技术社区  · 16 年前

    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();
         }
    }
    

    在客户机中:

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

    1 回复  |  直到 16 年前
        1
  •  5
  •   Adrian Serafin    16 年前

    mono中的unix套接字正常:)。我遇到了一些与Mono.Unix和Unix域套接字完全无关的线程问题。谢谢大家的帮助。