Skip to content

Commit 756eef2

Browse files
committed
memperbaiki error saat kompilasi
1 parent 1cd3aa5 commit 756eef2

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/transmitter.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
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-
816
using 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

1126
int main(int argc, char *argv[] ){
1227

1328
/* Create socket */
1429
struct sockaddr_in serv_addr;
1530
socklen_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);
1834
serv_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[] ){
5975
int i=1;
6076
char cc;
6177
FILE* myfile = fopen(argv[3], "r");
62-
while (!myfile.eof()){
78+
while (!feof(myfile)){
6379
fscanf(myfile, "%c", &cc);
6480
printf("Mengirim byte ke-%d: \'%c\' \n", i, cc);
6581
i++;

0 commit comments

Comments
 (0)