Beispiel #1
0
// Close the connection and release the console device
void telnetRelease(JsNetwork *net) {
  if (!(tnSrv.sock && tnSrv.cliSock)) return;
  printf("tnSrv: released console from sock %d\n", tnSrv.cliSock);
  netCloseSocket(net, tnSrv.cliSock);
  tnSrv.cliSock = 0;
  if (!jsiIsConsoleDeviceForced()) jsiSetConsoleDevice(tnSrv.oldConsole, false);
}
Beispiel #2
0
// Close the connection and release the console device
void telnetRelease(JsNetwork *net) {
  if (!(tnSrv.sock && tnSrv.cliSock)) return;
  printf("tnSrv: released console from sock %d\n", tnSrv.cliSock-1);
  netCloseSocket(net, tnSrv.cliSock-1);
  tnSrv.cliSock = 0;
  IOEventFlags console = jsiGetConsoleDevice();
  // only switch away from telnet if the current console is TELNET, this allows the current
  // console to be set to something else while connected via telnet and then not have it
  // switched again when disconnecting from telnet
  if (console == EV_TELNET && !jsiIsConsoleDeviceForced())
    jsiSetConsoleDevice(tnSrv.oldConsole, false);
}
Beispiel #3
0
// Attempt to accept a connection, returns true if it did something
bool telnetAccept(JsNetwork *net) {
  // we're gonna do a single accept per idle iteration for now
  if (tnSrv.sock == 0) return false;
  int sock = netAccept(net, tnSrv.sock);
  if (sock < 0) return false; // nothing

  // if we already have a client, then disconnect it
  if (tnSrv.cliSock != 0) {
    netCloseSocket(net, tnSrv.cliSock);
  }
  // if the console is not already telnet, then change it
  IOEventFlags console = jsiGetConsoleDevice();
  if (console != EV_TELNET) {
    tnSrv.oldConsole = console;
    if (!jsiIsConsoleDeviceForced()) jsiSetConsoleDevice(EV_TELNET, false);
  }

  tnSrv.cliSock = sock;
  printf("tnSrv: accepted console on sock=%d\n", sock);
  return true;
}