// This part was taken from Rick Parrish TelnetDoor almost direct copy pase, with some stuff removed. private static void Connect() { _Server = new TelnetConnection(); if (_Server.Connect(hostURL, _Port)) { bool CanContinue = true; if (CanContinue) { Door.PipeWrite = false; bool UserAborted = false; while (!UserAborted && Door.Carrier && _Server.Connected) { bool Yield = true; // See if the server sent anything to the client if (_Server.CanRead()) { Door.Write(_Server.ReadString()); Yield = false; } // See if the client sent anything to the server if (Door.KeyPressed()) { string ToSend = ""; while (Door.KeyPressed()) { byte B = (byte)Door.ReadByte(); ToSend += (char)B; } _Server.Write(ToSend); Yield = false; } // See if we need to yield if (Yield) Crt.Delay(1); } Door.PipeWrite = true; } } else { Door.WriteLn("Looks like the BBSLink server isn't online, please try back later."); } }
public TcpConnection AcceptTCP() { try { Socket NewSocket = _Socket.Accept(); TcpConnection NewConnection = new TcpConnection(); NewConnection.Open(NewSocket); return(NewConnection); } catch (SocketException sex) { RMLog.DebugException(sex, "SocketException in TcpConnection::AcceptTCP(). ErrorCode=" + sex.ErrorCode.ToString()); return(null); } catch (Exception ex) { RMLog.DebugException(ex, "Exception in TcpConnection::AcceptTCP()"); return(null); } }
public IPCSocketServerThread(TcpConnection serverConnection) { _Listener = serverConnection; }
public IPCSocketClientThread(TcpConnection clientConnection) { _ClientConnection = clientConnection; _RemoteIP = clientConnection.GetRemoteIP(); _RemotePort = clientConnection.GetRemotePort(); }
private static void Connect() { Door.WriteLn(); Door.Write(" Connecting to remote server..."); if (_RLogin) { _Server = new RLoginConnection(); } else { _Server = new TelnetConnection(); } // Sanity check on the port if ((_Port < 1) || (_Port > 65535)) { _Port = (_RLogin) ? 513 : 23; } if (_Server.Connect(_HostName, _Port)) { bool CanContinue = true; if (_RLogin) { // Send rlogin header _Server.Write("\0" + _RLoginClientUserName + "\0" + _RLoginServerUserName + "\0" + _RLoginTerminalType + "\0"); // Wait up to 5 seconds for a response char? Ch = _Server.ReadChar(5000); if ((Ch == null) || (Ch != '\0')) { CanContinue = false; Door.WriteLn("failed!"); Door.WriteLn(); Door.WriteLn(" Looks like the remote server doesn't accept RLogin connections."); } } if (CanContinue) { Door.WriteLn("connected!"); if (Door.Local) { Ansi.ESC5nEvent += new EventHandler(Ansi_ESC5nEvent); Ansi.ESC6nEvent += new EventHandler(Ansi_ESC6nEvent); Ansi.ESC255nEvent += new EventHandler(Ansi_ESC255nEvent); } Door.PipeWrite = false; bool UserAborted = false; while (!UserAborted && Door.Carrier && _Server.Connected) { bool Yield = true; // See if the server sent anything to the client if (_Server.CanRead()) { Door.Write(_Server.ReadString()); Yield = false; } // See if the client sent anything to the server if (Door.KeyPressed()) { string ToSend = ""; while (Door.KeyPressed()) { byte B = (byte)Door.ReadByte(); if (B == 29) { // Ctrl-] _Server.Close(); UserAborted = true; break; } else { ToSend += (char)B; } } _Server.Write(ToSend); if (Door.LocalEcho) Door.Write(ToSend); Yield = false; } // See if we need to yield if (Yield) Crt.Delay(1); } Door.PipeWrite = true; if (UserAborted) { Door.WriteLn(); Door.WriteLn(); Door.WriteLn(" User hit CTRL-] to disconnect from server."); } else if ((Door.Carrier) && (!_Server.Connected)) { Door.WriteLn(); Door.WriteLn(); Door.WriteLn(" Remote server closed the connection."); } } } else { Door.WriteLn("failed!"); Door.WriteLn(); Door.WriteLn(" Looks like the remote server isn't online, please try back later."); } }
public TcpConnection AcceptTCP() { try { Socket NewSocket = _Socket.Accept(); TcpConnection NewConnection = new TcpConnection(); NewConnection.Open(NewSocket); return NewConnection; } catch (SocketException sex) { RMLog.Exception(sex, "SocketException in TcpConnection::AcceptTCP(). ErrorCode=" + sex.ErrorCode.ToString()); return null; } catch (Exception ex) { RMLog.Exception(ex, "Exception in TcpConnection::AcceptTCP()"); return null; } }