File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed
Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change 11#include " dcomm.h"
2- #include < sys/socket.h>
2+ #include < stdlib.h>
3+ #include < stddef.h>
4+ #include < netinet/in.h>
5+ #include < arpa/inet.h>
6+ #include < iostream>
37#include < sys/types.h>
8+ #include < sys/socket.h>
9+ #include < strings.h>
410#include < string.h>
11+ #include < unistd.h>
12+ #include < netinet/in.h>
13+ #include < limits.h>
514#include < stdio.h>
615#include < pthread.h>
7-
816using namespace std ;
917
18+ void *childProcess (void *threadid){
19+ int byte_now = 0 ;
20+ while (true ){
21+ break ;
22+ }
23+ pthread_exit (NULL );
24+ }
1025
1126int main (int argc, char *argv[] ){
1227
1328/* Create socket */
1429struct sockaddr_in serv_addr;
1530socklen_t addrlen = sizeof (serv_addr);
31+ char clientName[1000 ];
1632
17- int serversock = socket (AF_INET, SOCK_DGRAM, 0 );
33+ int sockfd = socket (AF_INET, SOCK_DGRAM, 0 );
1834serv_addr.sin_family = AF_INET;
19- serv_addr.in_addr .s_addr = inet_addr (argv[1 ]);
35+ serv_addr.sin_addr .s_addr = inet_addr (argv[1 ]);
2036 if (argc > 2 ) {
2137 serv_addr.sin_port = htons (atoi (argv[2 ]));
2238 } else {
2339 serv_addr.sin_port = htons (13514 );
2440 }
2541
26- if (bind (serversock , (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0 ) {
42+ if (bind (sockfd , (struct sockaddr *) &serv_addr, sizeof (serv_addr)) < 0 ) {
2743 perror (" ERROR : on binding" );
2844 exit (1 );
2945 }
@@ -59,7 +75,7 @@ int main(int argc, char *argv[] ){
5975int i=1 ;
6076char cc;
6177FILE* myfile = fopen (argv[3 ], " r" );
62- while (!myfile. eof ( )){
78+ while (!feof (myfile )){
6379fscanf (myfile, " %c" , &cc);
6480printf (" Mengirim byte ke-%d: \' %c\' \n " , i, cc);
6581i++;
You can’t perform that action at this time.
0 commit comments