public AsyncClient(Socket Connection, string Key) { try { _InCipher = new xChatLib.External.RC4(Constants.Ansi.GetBytes(Key)); _OutCipher = new xChatLib.External.RC4(Constants.Ansi.GetBytes(Key)); _Socket = Connection; _Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, false); _Socket.BeginReceive(_Buffer, 0, _Buffer.Length, SocketFlags.None, new AsyncCallback(RecieveCallback), null); } catch (SocketException) { OnClientDisconnected(this, DisconnectionReason.SocketException); } }
public AsyncClient(IPAddress Address, ushort Port, string Key) { try { _InCipher = new xChatLib.External.RC4(Constants.Ansi.GetBytes(Key)); _OutCipher = new xChatLib.External.RC4(Constants.Ansi.GetBytes(Key)); _Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _Socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Linger, false); _Socket.Connect(new IPEndPoint(Address, Port)); _Socket.BeginReceive(_Buffer, 0, _Buffer.Length, SocketFlags.None, new AsyncCallback(RecieveCallback), null); } catch (SocketException) { OnClientDisconnected(this, DisconnectionReason.SocketException); } }