#include /* for NULL */ #include /* for perror() */ #include /* for atoi() */ #include /* for pid_t, socket.h */ #include /* for AF_INET, etc. */ #include /* for struct sockaddr_in */ #include /* for hostent */ #define SERVER_NAME "acmex.gatech.edu" #define SERVER_PORT (13) /* exit and print system error code */ static void die(char *s) { perror(s); exit(2); } static int main(void) { char msgbuf[BUFSIZ]; /* Buffer for receiving */ char response[BUFSIZ]; /* Buffer for sending */ int sock; /* The Socket */ int recvlen, sendlen, addrlen; /* store various things */ struct sockaddr_in addr; /* The address structure */ struct hostent *hentp; /* Used for finding the servers */ /* address. */ /* Record the size of the address structure */ addrlen = sizeof(addr); /* Initialize to zero */ memset((char *)&newAddr,0,sizeof(newAddr)); /* CREATE THE SOCKET */ /* your code here, Hint, use 'socket' */ /* Fill in the sockaddr_in structure, so connect() knows where to */ /* find the server */ if( hentp = gethostbyname( SERVER_NAME ) ) (void)memcpy((char *)&addr.sin_addr,hentp->h_addr,hentp->h_length); else die( "bad host name" ); addr.sin_family=AF_INET; addr.sin_port=htons(SERVER_PORT); /* CONNECT TO THE SERVER */ /* your code here. Use 'connect()' */ /* SEND DATA TO SERVER */ /* Your code here */ /* GET A REPLY */ /* Your code here */ /* PRINT THE REPLY */ /* display the server's reply to the user */ /* CLOSE CONNECTION */ /* Your code here */ return EXIT_SUCCESS; }