Пример #1
0
void connect_command(char* arg)
{
  char *host, *port;

  SocketFlags = SOCKECHO;
  State = 0;

  if ( MUDSocket ) {
        tintin_puts2(rs::rs(1162));
        return;
  }

  if ( WaitForSingleObject(hConnThread , 0 ) == WAIT_TIMEOUT ) {
        tintin_puts2(rs::rs(1162));
        return;
  }
  
  port=host=space_out(mystrdup(arg));

  if(!*host) {
    tintin_puts2(rs::rs(1164));
    return ;
  }

  while(*port && !isspace(*port))
    port++;
  *port++='\0';
  port=space_out(port);

  if(!*port) {
    tintin_puts2(rs::rs(1165));
    return ;
  }
  connect_mud(host, port);
}
Пример #2
0
struct session *connect_session(struct session *ses)
{
	int sock;

	push_call("connection_session(%p)",ses);

	ses->connect_retry = utime() + gts->connect_retry;

	reconnect:

	sock = connect_mud(ses, ses->host, ses->port);

	if (sock == -1)
	{
		cleanup_session(ses);

		pop_call();
		return NULL;
	}

	if (sock)
	{
		gtd->ses    = ses;
		ses->socket = sock;

		ses->connect_retry = 0;

		SET_BIT(ses->flags, SES_FLAG_CONNECTED);

		tintin_printf2(ses, "");

		tintin_printf(ses, "#SESSION '%s' CONNECTED TO '%s' PORT '%s'", ses->name, ses->host, ses->port);

		check_all_events(ses, SUB_ARG|SUB_SEC, 0, 4, "SESSION CONNECTED", ses->name, ses->host, ses->ip, ses->port);

		pop_call();
		return ses;
	}

	if (ses->connect_retry > utime())
	{
		goto reconnect;
	}

	if (ses->connect_error)
	{
		tintin_printf(ses, "#SESSION '%s' FAILED TO CONNECT.", ses->name);
	}

	cleanup_session(ses);

	pop_call();
	return NULL;
}