public MqttTcpServerListener( AddressFamily addressFamily, MqttServerTcpEndpointBaseOptions options, X509Certificate2 tlsCertificate, CancellationToken cancellationToken, IMqttNetChildLogger logger) { _cancellationToken = cancellationToken; _logger = logger; _addressFamily = addressFamily; var sb = new SocketOptionBuilder().SetSocket(Sockets.Model.SocketType.Tcp).UseStream(); if (options is MqttServerTlsTcpEndpointOptions tlsOptions) { sb = sb.WithSsl(tlsCertificate, tlsOptions.SslProtocol); } sb = sb.SetPort(options.Port); if (_addressFamily == AddressFamily.InterNetworkV6) { sb = sb.UseIPV6(); } socketOption = sb.Build(); serverSokcet = SocketFactory.CreateServerSocket(socketOption, cancellationToken); serverSokcet.OnAccepted += ServerSokcet_OnAccepted; }
public MessageServer(int port = 39654, int bufferSize = 102400, int count = 1000, int timeOut = 60 * 1000) { var option = SocketOptionBuilder.Instance .SetPort(port) .UseIocp <MessageContext>() .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetCount(count) .SetTimeOut(timeOut) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnAccepted += _server_OnAccepted; _server.OnReceive += _server_OnReceive; _server.OnError += _server_OnError; _server.OnDisconnected += _server_OnDisconnected; _classificationBatcher = ClassificationBatcher.GetInstance(10000, 10); _classificationBatcher.OnBatched += _classificationBatcher_OnBatched; }
public MyServer() { var option = SocketOptionBuilder.Instance.UseIocp(new MyContext()) .SetPort(39654) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnReceive += _server_OnReceive; }
public WSSServerImpl(SslProtocols sslProtocols, string pfxPath, string pwd = "", int port = 39654, int bufferSize = 1024) { _bufferSize = bufferSize; var builder = SocketOptionBuilder.Instance.UseStream().SetPort(port).WithSsl(sslProtocols, pfxPath, pwd); var options = builder.Build(); serverSokcet = SocketFactory.CreateServerSocket(options); serverSokcet.OnAccepted += ServerSokcet_OnAccepted; }
public HttpSocket(int port, int bufferSize = 1024 * 10, int count = 10000, int timeOut = 120 * 1000) { var optionBuilder = new SocketOptionBuilder() .SetSocket(Sockets.Model.SocketType.Tcp) .UseIocp(new HContext()) .SetPort(port) .SetCount(count) .SetBufferSize(bufferSize) .SetTimeOut(timeOut); var option = optionBuilder.Build(); _serverSokcet = SocketFactory.CreateServerSocket(option); _serverSokcet.OnReceive += _serverSokcet_OnReceive; }
public WSServerImpl(int port = 39654, int bufferSize = 1024, int count = 60000) { var option = SocketOptionBuilder.Instance .SetSocket() .UseIocp(new WSContext()) .SetPort(port) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetCount(count) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnReceive += _server_OnReceive; }
public EventSocketServer(string ipAddress, int port) { ISocketOption option = SocketOptionBuilder.Instance.UseIocp(new Context()) .SetIP(ipAddress) .SetPort(port) .SetSocket(SAEA.Sockets.Model.SAEASocketType.Tcp) //.SetCount(ushort.MaxValue) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnAccepted += _server_OnAccepted; _server.OnDisconnected += _server_OnDisconnected; _server.OnError += _server_OnError; _server.OnReceive += _server_OnReceive; }
public HttpSocketDebug(int port, int bufferSize = 1024 * 10, int count = 10000, int timeOut = 120 * 1000) { var optionBuilder = new SocketOptionBuilder() .SetSocket(Sockets.Model.SAEASocketType.Tcp) .UseIocp <HContext>() .SetPort(port) .SetCount(count) .SetReadBufferSize(bufferSize) .SetTimeOut(timeOut) .ReusePort(false); _option = optionBuilder.Build(); _serverSokcet = SocketFactory.CreateServerSocket(_option); _serverSokcet.OnReceive += _serverSokcet_OnReceive; }
/// <summary> /// http2服务端 /// </summary> /// <param name="invoker"></param> /// <param name="port"></param> /// <param name="count"></param> /// <param name="size"></param> /// <param name="timeOut"></param> public Http2Server(IHttp2Invoker invoker = null, int port = 39654, int count = 100, int size = 1024, int timeOut = 180 * 1000) { var options = SocketOptionBuilder.Instance.SetSocket(Sockets.Model.SAEASocketType.Tcp) .UseStream() .SetPort(port) .SetCount(count) .SetReadBufferSize(size) .SetWriteBufferSize(size) .SetTimeOut(timeOut) .Build(); _invoker = invoker; _serverSocket = SocketFactory.CreateServerSocket(options); _serverSocket.OnAccepted += _serverSocket_OnAccepted; }
public RServer(int port = 39654, int bufferSize = 100 * 1024, int count = 10000) { var option = SocketOptionBuilder.Instance .SetSocket() .UseIocp <RContext>() .SetPort(port) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetCount(count) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnError += _server_OnError; _server.OnReceive += _server_OnReceive; }
public MessageServer(int port = 39654, int bufferSize = 1024, int count = 1000000, int timeOut = 60 * 1000) { var option = SocketOptionBuilder.Instance .SetPort(port) .UseIocp(new MessageContext()) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetCount(count) .SetTimeOut(timeOut) .Build(); _server = SocketFactory.CreateServerSocket(option); _server.OnReceive += _server_OnReceive; _server.OnDisconnected += _server_OnDisconnected; }
public HttpSocket(int port, int bufferSize = 1024 * 10, int count = 10000, int timeOut = 120 * 1000, bool isDebug = false) { var optionBuilder = new SocketOptionBuilder() .SetSocket(SAEASocketType.Tcp) .UseIocp(new HContext()) .SetPort(port) .SetCount(count) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetTimeOut(timeOut); var option = optionBuilder.Build(); _serverSokcet = SocketFactory.CreateServerSocket(option); _serverSokcet.OnReceive += _serverSokcet_OnReceive; IsDebug = isDebug; }
public WSSServerImpl(SslProtocols sslProtocols, string pfxPath, string pwd = "", int port = 16666, int bufferSize = 1024) { _bufferSize = bufferSize; var builder = SocketOptionBuilder.Instance .UseStream() .SetPort(port) .WithSsl(sslProtocols, pfxPath, pwd); var options = builder.Build(); serverSokcet = SocketFactory.CreateServerSocket(options); serverSokcet.OnAccepted += ServerSokcet_OnAccepted; serverSokcet.OnDisconnected += ServerSokcet_OnDisconnected; _concurrentDictionary = new ConcurrentDictionary <string, WSCoder>(); }
public FTPDataSocketManager(string userName, ushort port, int bufferSize = 10240) { _autoResetEvent = new AutoResetEvent(false); var option = SocketOptionBuilder.Instance .SetSocket() .UseIocp() .SetPort(port) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .Build(); var dataSocket = SocketFactory.CreateServerSocket(option); dataSocket.OnAccepted += DataSocket_OnAccepted; dataSocket.OnDisconnected += DataSocket_OnDisconnected; dataSocket.OnError += _serverSocket_OnError; dataSocket.OnReceive += DataSocket_OnReceive; _dataSocket = dataSocket; _userName = userName; _dataSocket.Start(); }
public QServer(int port = 39654, string ip = "127.0.0.1", int bufferSize = 1000 * 1024, int count = 1000, int maxNum = 500, int maxTime = 500) { _maxNum = maxNum; _maxTime = maxTime; _exchange = new Exchange(); var config = SocketOptionBuilder.Instance .UseIocp <QContext>() .SetSocket(Sockets.Model.SAEASocketType.Tcp) .SetReadBufferSize(bufferSize) .SetWriteBufferSize(bufferSize) .SetCount(count) .SetIP(ip) .SetPort(port) .Build(); _serverSokcet = SocketFactory.CreateServerSocket(config); _serverSokcet.OnReceive += _serverSokcet_OnReceive; _serverSokcet.OnDisconnected += _serverSokcet_OnDisconnected; }
public void Dispose() { _dataSocket?.Dispose(); _dataSocket = null; }