protected override void Start(SocketContext context) { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); SocketAsyncProxy.Initialize(Client, this, context); SayWelcome(); StartReceive(SocketAsyncProxy.SocketEventArgs); }
public override void Initialize() { if (Client != null) { //-------------------初始化心跳检测---------------------// uint dummy = 0; _KeepAliveOptionValues = new byte[Marshal.SizeOf(dummy) * 3]; _KeepAliveOptionOutValues = new byte[_KeepAliveOptionValues.Length]; BitConverter.GetBytes((uint)1).CopyTo(_KeepAliveOptionValues, 0); BitConverter.GetBytes((uint)(2000)).CopyTo(_KeepAliveOptionValues, Marshal.SizeOf(dummy)); uint keepAlive = this.Server.Config.KeepAlive; BitConverter.GetBytes((uint)(keepAlive)).CopyTo(_KeepAliveOptionValues, Marshal.SizeOf(dummy) * 2); Client.IOControl(IOControlCode.KeepAliveValues, _KeepAliveOptionValues, _KeepAliveOptionOutValues); Client.NoDelay = true; Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); //----------------------------------------------------// Client.ReceiveTimeout = Server.Config.NetReceiveTimeout; Client.SendTimeout = Server.Config.NetSendTimeout; Client.ReceiveBufferSize = Server.Config.NetReceiveBufferSize; Client.SendBufferSize = Server.Config.NetSendBufferSize; } if (SocketAsyncProxy != null) { SocketAsyncProxy.Initialize(this); SocketAsyncProxy.SocketReceiveEventArgs.Completed += SocketEventArgs_Completed; SocketAsyncProxy.SocketSendEventArgs.Completed += SocketEventArgs_Completed; } }
public override void Start() { SocketAsyncProxy.Initialize(this); StartReceive(SocketAsyncProxy.SocketEventArgs); if (!m_IsReset) { StartSession(); } }
public override void Initialize(IAppSession appSession) { base.Initialize(appSession); //Initialize SocketAsyncProxy for receiving SocketAsyncProxy.Initialize(this); if (!SyncSend) { //Initialize SocketAsyncEventArgs for sending m_SocketEventArgSend = new SocketAsyncEventArgs(); m_SocketEventArgSend.Completed += new EventHandler <SocketAsyncEventArgs>(OnSendingCompleted); } }
public override void Start() { SocketAsyncProxy.Initialize(this); StartReceive(SocketAsyncProxy.SocketEventArgs); if (!SyncSend) { m_SocketEventArgSend = new SocketAsyncEventArgs(); m_SocketEventArgSend.Completed += new EventHandler <SocketAsyncEventArgs>(OnSendingCompleted); } if (!m_IsReset) { StartSession(); } }
private void Dispose(bool disposing) { if (!this._IsDisposed) { if (disposing) { Client.SafeClose(); Client.Dispose(); Client = null; SocketAsyncProxy.Reset(); } _IsDisposed = true; } }
public void Initialize(IAppSession appSession) { this.AppSession = appSession as AppSession; SendingQueue queue; if (m_SendingQueuePool.TryGet(out queue)) { m_SendingQueue = queue; queue.StartEnqueue(); } SocketAsyncProxy.Initialize(this); //Initialize SocketAsyncEventArgs for sending m_SocketEventArgSend = new SocketAsyncEventArgs(); m_SocketEventArgSend.Completed += new EventHandler <SocketAsyncEventArgs>(OnSendingCompleted); }
public override void Start() { SocketAsyncProxy.Initialize(Client, this); StartSession(); StartReceive(SocketAsyncProxy.SocketEventArgs); }
public override void Start() { Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); SocketAsyncProxy.Initialize(Client, this); ContinueToListen(SocketAsyncProxy.SocketEventArgs); }