#include "syncboot.h" #include #include #include #include #include #include #include #include #include #include int main( int argc, char* argv[] ) { int CltSocket, Status = 0; char *RemHost = NULL; char *ProgName = basename( argv[0] ); char Buff[256] = ""; struct hostent *pHostEnt; struct sockaddr_in SrvName; RemHost = argv[1]; CltSocket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP ); if( CltSocket == -1 ) { perror( "Can't create socket!\n" ); exit( 1 ); } pHostEnt = gethostbyname( RemHost ); if( ! pHostEnt ) { pHostEnt = gethostbyaddr( RemHost, strlen( RemHost ), AF_INET ); } if( ! pHostEnt ) { fprintf( stderr,"%s: Couldn't resolve remote host %s", ProgName, RemHost ); exit( 1 ); } SrvName.sin_family = AF_INET; SrvName.sin_port = htons( PORT ); memcpy( &SrvName.sin_addr, pHostEnt->h_addr, pHostEnt->h_length ); Status = connect( CltSocket, (struct sockaddr*)&SrvName, sizeof( SrvName ) ); if( Status == -1 ) { perror( "Can't connect!\n" ); exit( 1 ); } while( ( Status = read( CltSocket, Buff, sizeof( Buff) -1 ) ) > 0 ) { printf( "%d : %s\n", Status, Buff ); } if( Status == -1 ){ perror( "Read error!\n" ); } close( CltSocket ); exit( 0 ); }