public QClient(string name, int bufferSize = 100 * 1024, string ip = "127.0.0.1", int port = 39654) { _name = name; HeartSpan = 1000 * 1000; HeartAsync(); _batcher = new Batcher <byte[]>(3000, 10); //此参数用于控制产生或消费速读,过大会导致溢出异常 _batcher.OnBatched += _batcher_OnBatched; _qUnpacker = new QUnpacker(); _queueCoder = new QueueCoder(); ISocketOption socketOption = SocketOptionBuilder.Instance.SetSocket(Sockets.Model.SAEASocketType.Tcp) .UseIocp <QUnpacker>() .SetIP(ip) .SetPort(port) .SetWriteBufferSize(bufferSize) .SetReadBufferSize(bufferSize) .ReusePort(false) .Build(); _clientSocket = SocketFactory.CreateClientSocket(socketOption); _clientSocket.OnReceive += _clientSocket_OnReceive; _clientSocket.OnError += _clientSocket_OnError; _clientSocket.OnDisconnected += _clientSocket_OnDisconnected; }