/// <summary> /// 启动服务 /// </summary> /// <param name="endpoint"></param> /// <returns></returns> public void Start(IPEndPoint endpoint) { if (!_run) { _run = true; try { _udpServer = SocketFactory.CreateServerSocket(SocketOptionBuilder.Instance.SetSocket(SAEASocketType.Udp) .SetIPEndPoint(endpoint) .UseIocp <BaseContext>() .SetReadBufferSize(SocketOption.UDPMaxLength) .SetWriteBufferSize(SocketOption.UDPMaxLength) .SetTimeOut(UDP_TIMEOUT) .SetFreeTime(30 * 1000) .Build()); _udpServer.OnError += _udpServer_OnError; _udpServer.OnReceive += _udpServer_OnReceive; _udpServer.Start(); OnEvent(OnListening, EventArgs.Empty); } catch (SocketException e) { OnError(e); return; } } }
private void StartService() { try { DBShare.MainOutMessage("正在启动服务器..."); DBShare.LoadConfig(); ServerSocket.Start(new IPEndPoint(IPAddress.Parse("0.0.0.0"), DBShare.g_nServerPort)); SelectSocket.Start(new IPEndPoint(IPAddress.Parse("0.0.0.0"), DBShare.g_nGatePort)); DBShare.g_boStartService = true; FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.OpenConnect(); }); this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_START.Enabled = false; }); this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_STOP.Enabled = true; }); DBShare.MainOutMessage("数据库服务器启动成功..."); DBShare.SendGameCenterMsg(Common.SG_STARTOK, "数据库服务器启动完成..."); } catch (Exception ex) { DBShare.MainOutMessage(ex.Message); DBShare.g_boStartService = false; this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_START.Enabled = true; }); this.Invoke((MethodInvoker) delegate() { MENU_CONTROL_STOP.Enabled = false; }); FrmIDSoc.Invoke((MethodInvoker) delegate() { FrmIDSoc.CloseConnect(); }); SelectSocket.Shutdown(); ServerSocket.Shutdown(); } }
public void Start(int port) { _server = new IServerSocket(10, 1024 * 4); _server.Init(); _server.Start("0.0.0.0", port); _server.OnClientConnect += _server_OnClientConnect; _server.OnClientRead += _server_OnClientRead; _server.OnClientDisconnect += _server_OnClientDisconnect; }
public void StartMsgServer() { try { MsgServer = new IServerSocket(20, Int16.MaxValue); MsgServer.Init(); MsgServer.Start(M2Share.g_Config.sMsgSrvAddr, M2Share.g_Config.nMsgSrvPort); } catch { M2Share.MainOutMessage("{Òì³£} TFrmSrvMsg::StartMsgServer"); } }
public bool Start(bool treatErrorsAsWarning, CancellationToken cancellationToken) { try { var builder = SocketOptionBuilder.Instance; var boundIp = _options.BoundInterNetworkAddress; if (_addressFamily == AddressFamily.InterNetworkV6) { builder = builder.UseIPv6(); boundIp = _options.BoundInterNetworkV6Address; } _localEndPoint = new IPEndPoint(boundIp, _options.Port); _logger.Info($"Starting TCP listener for {_localEndPoint} TLS={_tlsCertificate != null}."); builder = builder.ReusePort(_options.ReuseAddress); if (!_options.NoDelay) { builder = builder.SetDelay(); } if (_tlsCertificate != null) { builder = builder.WithSsl(_tlsCertificate, System.Security.Authentication.SslProtocols.Tls12); } _serverSokcet = SocketFactory.CreateServerSocket(builder.UseStream().SetIPEndPoint(_localEndPoint).Build()); _serverSokcet.OnAccepted += _serverSokcet_OnAccepted; _serverSokcet.Start(_options.ConnectionBacklog); return(true); } catch (Exception exception) { if (!treatErrorsAsWarning) { throw; } _logger.Warning(exception, "Error while creating listener socket for local end point '{0}'.", _localEndPoint); return(false); } }
public virtual void StartServer(SocketConfig socketConfig) { SocketConfig = socketConfig; foreach (var module in _moduleManager.ForeachInitializedModule()) { var serverModule = module.Value; if (serverModule.ServiceId != ID) { continue; } RpcMethodIds.AddRange(serverModule.RpcMethodIds); RpcPacketTypes.AddRange(serverModule.RpcPacketTypes); } _serverSocket.Start(socketConfig); }
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 void Start(int backlog = 10 * 1000) { _serverSokcet.Start(backlog); _calcBegin = true; }
public void Start(int backlog = 10000) { _server.Start(backlog); }
public void Start() { _serverSokcet.Start(); }
public void Start(int backlog = 10000) { serverSokcet.Start(backlog); }
/// <summary> /// Start /// </summary> public void Start() { _udpServer.Start(); }
internal void Start() { _server.Start(); }
public void Start() { _server.Start(); }