private void receiveCallback(IAsyncResult ar) { IRCIdentStateObject so = (IRCIdentStateObject)ar.AsyncState; int intRead = so.socket.EndReceive(ar); if (so.socket.Connected) { if (intRead > 0) { string strData = Encoding.Default.GetString(so.buffer, 0, intRead); strData = strData.Replace("\r", "").Replace("\n", ""); if (strData.IndexOf(",") > -1) { string[] strPorts = strData.Split(new char[] { ',' }); if (strPorts.Length == 2 && strPorts[0].Trim() == base.CurrentConnection.LocalPort.ToString() && strPorts[1].Trim() == base.CurrentConnection.RemotePort.ToString()) { SendData(strData + " : Identity : " + strOS + " : " + ircParent.Identity, so.socket, true); } else { SendData(strData + " : ERROR : NO-USER", so.socket, false); } } else { so.socket.Shutdown(SocketShutdown.Both); so.socket.Close(); so.socket = null; } } else { so.socket.Shutdown(SocketShutdown.Both); so.socket.Close(); so.socket = null; } } }
private void incomingConnection(IAsyncResult ar) { if (listenSocket != null) { Socket newSocket = listenSocket.EndAccept(ar); this.Listen = false; if (newSocket != null && newSocket.Connected) { if (CompareAddressBytes(((IPEndPoint)newSocket.RemoteEndPoint).Address.GetAddressBytes(), base.CurrentConnection.RemoteIP)) { IRCIdentStateObject so = new IRCIdentStateObject(newSocket); newSocket.BeginReceive(so.buffer, 0, IRCIdentStateObject.bufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), so); } else { newSocket.Shutdown(SocketShutdown.Both); newSocket.Close(); newSocket = null; } } } }
private void incomingConnection(IAsyncResult ar) { if (listenSocket != null) { Socket newSocket = listenSocket.EndAccept(ar); this.Listen = false; if (newSocket != null && newSocket.Connected) { if (CompareAddressBytes(((IPEndPoint)newSocket.RemoteEndPoint).Address.GetAddressBytes(), base.CurrentConnection.RemoteIP)) { IRCIdentStateObject so = new IRCIdentStateObject(newSocket); newSocket.BeginReceive(so.buffer, 0, IRCIdentStateObject.bufferSize, SocketFlags.None, new AsyncCallback(receiveCallback), so); } else { newSocket.Shutdown(SocketShutdown.Both); newSocket.Close(); newSocket = null; } } } }