[RC5] Personal proxy

Chris Adams chris at improbable.org
Mon Dec 27 11:03:29 EST 1999


> If not, maybe Be would be a good platform?  Any idea what kind of network
>API it has?  (BSD-style sockets would be perfect, since it is widely
>used.)  If you aren't a programmer, you can see what Be does seeing if

BeOS has two network kits - an object-oriented C++ API and a BSD sockets-
derived layer to go with the rest of the POSIX stuff. It didn't take long to 
get the rc5des client source to compile.

(I'd second your recommendation of BeOS, BTW. It's the only OS he mentioned 
that I'd consider server-class.)

Here's the version of your code modified for BeOS. arpa/inet.h was commented 
out & PF_INET was replaced with AF_INET.

#define _GNU_SOURCE

#include <stdio.h>

#include <netdb.h>
#include <netinet/in.h>
//#include <arpa/inet.h>
#include <sys/socket.h>

int main( int argc, char ** argv ){

        int sock;
        struct hostent *server_info;
        char *server = "us.v27.distributed.net";

        sock = socket( AF_INET, SOCK_STREAM, 0 );
        perror( "socket" );
        printf( "socket() returned %d\n", sock );
        if( socket < 0 ){
                puts( "can't even create a socket :(");
                return 1;
        }

        server_info = gethostbyname( server );
        if( NULL == server_info ){
                herror( server );
                printf( "Couldn't find an IP address for %s :(\n", server );
                return 1;
        }

        printf( "%s => %s\n", server,
                inet_ntoa( *(struct in_addr *) (server_info->h_addr) ) );

        puts( "Can create sockets and look up hostnames.  "
                "Your machine probably works :)" );

        return 0;
}            
-- 
# Chris Adams <chris at improbable.org>

Mr. Cole's Axiom:
	The sum of the intelligence on the planet is a constant; the
population is growing.

--
To unsubscribe, send 'unsubscribe rc5' to majordomo at lists.distributed.net
rc5-digest subscribers replace rc5 with rc5-digest



More information about the rc5 mailing list