void ReleaseSocketAsync(saea e) { if (e._socket != null) { Console.WriteLine("A client {0} Release", e._socket.RemoteEndPoint); try { if (e._socket != null) { e._socket.Shutdown(SocketShutdown.Both); } } catch { } try { if (e._socket != null) { e._socket.Close(); } } catch { } initConfig.socketasync_queue.saea_enq(e); } }
internal void processReceive(saea e) { try { //aq aq = e._aq; if (e.BytesTransferred > 0 && e.SocketError == SocketError.Success) { Console.WriteLine(e.BytesTransferred); if (!e._socket.ReceiveAsync(e)) { Console.WriteLine("------------------------------------------------------------------"); //同步接收完成处理事件 processReceive(e); } } else { ReleaseSocketAsync(e); } } catch (Exception) { throw; } }
public void saea_enq(saea e) { lock (this) { socketAsync_Queue.Enqueue(e); Console.WriteLine(socketAsync_Queue.Count); } }
protected saea saeaEntry() { saea _saea; if (this._receviceBuffLength > 0) { _saea = new saea(this._receviceBuffLength); } else { _saea = new saea(); } return(_saea); }
private void handle_Socket(Socket se) { //aq aq = new aq(se._socket); //this.OnConnected(aq); //取出队列 saea _socketasync = initConfig.socketasync_queue.saea_dep(); _socketasync._socket = se; try { if (!_socketasync._socket.ReceiveAsync(_socketasync)) { //同步接收完成处理事件 _socketasync.processReceive(_socketasync); } } catch (Exception) { throw; } }
internal void processSend(saea e) { }