Пример #1
0
PCLIENT ConnectToRelay( PCLIENT *pc )
{
    TEXTCHAR address[128];
    if( InProgress )
    {
        BasicMessageBox( WIDE("Request in progress"), WIDE("Please wait a moment for\n")
                         WIDE("the current operation to finish") );
        return NULL;
    }
    InProgress = TRUE;
    NetworkWait( NULL, 5, 16 );
    GetControlText( GetControl( frame, EDT_SERVER ), address, sizeof( address ) );

    *pc = OpenTCPClientEx( address, 3001, ReadComplete, ConnectionClose, NULL );
    if( !(*pc) )
    {
        BasicMessageBox( WIDE("Bad Address?"),
                         WIDE("Check the address - could not connect") );
        return NULL;
    }
    ppc_current = pc;
    {
        FILE *file = sack_fopen( 0, WIDE("LastConnection.data"), WIDE("wb") );
        if( file )
        {
            fprintf( file, WIDE("%s"), address );
            fclose( file );
        }
    }
    return *pc;
}
Пример #2
0
/*********************************************************************************
 * Networkthread for background network initialize and update check with idle prio
 *********************************************************************************/
static void * networkinitcallback(void *arg)
{
	while (1)
	{
		if (!checkincomming && networkHalt)
			LWP_SuspendThread(networkthread);

		Initialize_Network();

		if (networkinitialized == true && updatechecked == false)
		{

			if (CheckUpdate() > 0) updateavailable = true;

			//suspend thread
			updatechecked = true;
			networkHalt = true;
		}

		if (checkincomming) NetworkWait();

		usleep(100000);
	}
	return NULL;
}
Пример #3
0
SaneWinMain( argc, argv )
{
	InitJSON();

	NetworkWait( NULL, 1024, 1 );
 
	gsg.server = WebSocketCreate( "0.0.0.0:27843/org.d3x0r/games/directory"
										 , OnOpen
										 , OnEvent
										 , OnClose
										 , Onerror
										 , 0 );
	while( 1 )
      WakeableSleep( 10000 );
}
Пример #4
0
int main( int argc, char **argv )
{
	if( argc < 1 )
	{
		printf( WIDE("Usage: %s <IP>\n"), argv[0] );
      return 1;
	}
   if( NetworkWait(NULL,1,0) )
	{
		unsigned long dwIP = inet_addr( argv[1] );
		struct hostent *phe;

		phe = gethostbyaddr( (char*)&dwIP, 4, AF_INET );
		if( phe )
		{
         char **alias = phe->h_aliases;
			printf( WIDE("%s %s"), argv[1], phe->h_name );
			while( alias[0] )
			{
				printf( WIDE("or %s"), alias[0] );
				alias++;
			}
			printf( WIDE("\n") );
         alias = phe->h_addr_list;
			while( alias[0] )
			{
				printf( WIDE("%d.%d.%d.%d ")
						, alias[0][0]
						, alias[0][1]
						, alias[0][2]
						, alias[0][3]
						);
				alias++;
			}
		}
		else
         printf( WIDE("%s has no name\n"), argv[1] );
	}
	else
      printf( WIDE("Failed to enable network.") );
	return 0;
}
Пример #5
0
SaneWinMain( argc, argv )
{
	if( argc < 1 )
	{
		printf( WIDE("Usage: %s <name>\n"), argv[0] );
      return 1;
	}
   if( NetworkWait(NULL,1,0) )
	{
		SOCKADDR *sa = CreateRemote( argv[1], 5555 );
		uint32_t IP;
		GetAddressParts( sa, &IP, NULL );

		printf( WIDE("%")_32f WIDE(".%")_32f WIDE(".%")_32f WIDE(".%")_32f WIDE("")
				, (IP & 0xFF)
				, (IP & 0xFF00) >> 8
				, (IP & 0xFF0000) >> 16
				, (IP & 0xFF000000) >> 24
				);
	}