4
This commit is contained in:
30
server-exp3/togglec.c
Normal file
30
server-exp3/togglec.c
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "common.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int client_sock, port;
|
||||
char *host, buf[MAXLINE];
|
||||
rio_t rio;
|
||||
|
||||
if (argc != 3) {
|
||||
fprintf(stderr, "usage: %s <host><port>\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
host = argv[1];
|
||||
port = atoi(argv[2]);
|
||||
|
||||
client_sock = open_client_sock(host, port);
|
||||
if(client_sock==-1) {
|
||||
fputs("Error to connect the Server\n",stdout);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
while (fgets(buf, MAXLINE, stdin) != NULL) {
|
||||
//sleep(1);
|
||||
send(client_sock, buf, strlen(buf),0);
|
||||
recv(client_sock, buf, MAXLINE,0);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
close(client_sock);
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user