Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed compiler bugs, ld error on output file for writing

  • Loading branch information...
commit 34362d1afc2bd78dc422f95860890624936eb990 1 parent 7eb8501
@rgharpuray authored
Showing with 9 additions and 14 deletions.
  1. +4 −9 src/udptestclient.c
  2. +5 −5 src/udptestserv.c
View
13 src/udptestclient.c
@@ -20,20 +20,15 @@ int main(int argc, char **argv)
char payload[PAYLOAD_SIZE];
portnum = atoi(argv[1]);
-
//socket
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if(sockfd < 0) printf("Couldn't open socket.\n");
- unsigned int addr = inet_addr("111:111:111:111");
- hostent *he = gethostbyaddr((char *) &addr, 4, AF_INET);
-
-
//setup info about server
- bzero((char *) &server_addr, sizeof(serveraddr));
+ bzero((char *) &server_addr, sizeof(server_addr));
server_addr.sin_family = AF_INET;
- bcopy((char *)server->h_addr, (char *)&serveraddr.sin_addr.s_addr, server->h_length);
- serveraddr.sin_port = htons(portnum);
+ bcopy((char *)server->h_addr, (char *)&server_addr.sin_addr.s_addr, server->h_length);
+ server_addr.sin_port = htons(portnum);
//get message from user
memset(payload, PAYLOAD_SIZE, 0);
@@ -44,7 +39,7 @@ int main(int argc, char **argv)
int send_result = sendto(sockfd, payload, strlen(payload), 0, &server_addr, serverlen);
if(send_result < 0) printf("Error in sending UDP packet\n");
- int serv_reply_result = recvfrom(sockfd, payload, strlen(payload), 0, &serveraddr, &serverlen);
+ int serv_reply_result = recvfrom(sockfd, payload, strlen(payload), 0, &server_addr, &serverlen);
if(serv_reply_result < 0) printf("Error: didnt receive reply properly from server\n");
printf("Served replied with %s\n", payload);
View
10 src/udptestserv.c
@@ -27,13 +27,13 @@ int main(int argc, char **argv)
if(sockfd < 0) printf("Couldn't open socket.\n");
//setup server's inet address info
- bzero((char *) &server_addr, sizeof(server_addr));
- server_addr.sin_family = AF_INET;
- server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- server_addr.sin_port = htons((unsigned short)portnum);
+ bzero((char *) &serv_addr, sizeof(serv_addr));
+ serv_addr.sin_family = AF_INET;
+ serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ serv_addr.sin_port = htons((unsigned short)portnum);
//bind the parent socket to the port
- int bind_result = bind(sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr));
+ int bind_result = bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
if(bind_result < 0) printf("Bind error.\n");
clientlen = sizeof(client_addr);
Please sign in to comment.
Something went wrong with that request. Please try again.