- Timestamp:
- Jul 15, 2011, 4:36:44 PM (13 years ago)
- Location:
- icas_send
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
icas_send/Makefile
r245 r246 1 1 all: 2 gcc icas_send.c -o icas_send 3 gcc icas_recv.c -o icas_recv 2 gcc icas_send.c -o icas_send -static 3 gcc icas_recv.c -o icas_recv -static 4 strip icas_send 5 strip icas_recv 4 6 clean: 5 7 rm icas_send icas_recv -
icas_send/icas_recv.c
r245 r246 22 22 int recv_length = sizeof(recv_sockopt); 23 23 int received; 24 char BLACK_LIST[ 256];24 char BLACK_LIST[1024]; 25 25 26 26 if (argc <= 1) … … 52 52 fprintf(stderr,"Finished binding port #%s for icas_recv socket.\n",argv[1]); 53 53 54 if ((received = recvfrom(recv_sock, BLACK_LIST, sizeof(BLACK_LIST), 0, (struct sockaddr *) &recv_sockopt, (socklen_t *) &recv_length)) < 0)54 while(1) 55 55 { 56 Die("Failed to receive message"); 56 if ((received = recvfrom(recv_sock, BLACK_LIST, sizeof(BLACK_LIST), 0, 57 (struct sockaddr *) &recv_sockopt, 58 (socklen_t *) &recv_length)) < 0) 59 { 60 Die("Failed to receive message"); 61 } 62 fprintf(stderr,"Received: %s\n", BLACK_LIST); 57 63 } 58 fprintf(stderr,"Received: %s\n", BLACK_LIST);59 64 60 65 close(recv_sock); -
icas_send/icas_send.c
r245 r246 18 18 int main(int argc, char *argv[]) 19 19 { 20 struct sockaddr_in send_sockopt; 21 int send_sock; 22 int send_length = sizeof(send_sockopt); 23 char BLACK_LIST[256]; 20 struct sockaddr_in send_sockopt; 21 int send_sock; 22 int send_length = sizeof(send_sockopt); 23 FILE *fd; 24 char BLACK_LIST[1024]; 25 size_t len = 0; 26 ssize_t read; 24 27 25 28 if (argc <= 2) 26 29 { 27 30 fprintf(stderr, "USAGE: %s <RECV_IP> <RECV_PORT>\n", argv[0]); 31 exit(1); 32 } 33 34 /* open blacklist to read black list data */ 35 fd = fopen("blacklist","r"); 36 if (fd == NULL) 37 { 38 fprintf(stderr, "%s: Couldn't open file %s; %s\n", argv[0], "blacklist", strerror (errno)); 28 39 exit(1); 29 40 } … … 45 56 send_sockopt.sin_port = htons(atoi(argv[2])); /* server port */ 46 57 47 if (sendto(send_sock, BLACK_LIST, sizeof(BLACK_LIST), 0, 48 (struct sockaddr *) &send_sockopt, 49 sizeof(send_sockopt)) != sizeof(BLACK_LIST)) { 50 Die("1: Mismatch in number of sent bytes"); 58 while(fgets(BLACK_LIST,sizeof(BLACK_LIST),fd)) 59 { 60 if (sendto(send_sock, BLACK_LIST, sizeof(BLACK_LIST), 0, 61 (struct sockaddr *) &send_sockopt, 62 sizeof(send_sockopt)) != sizeof(BLACK_LIST)) 63 { 64 Die("1: Mismatch in number of sent bytes"); 65 } 51 66 } 52 67
Note: See TracChangeset
for help on using the changeset viewer.