Skip to content

Commit

Permalink
fixed scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-who committed Apr 26, 2024
1 parent d4ecc52 commit 2e7799c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions spit/sat.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ void *httpd(void *arg) {
void *receiver(void *arg) {
threadMsgType *tc = (threadMsgType *) arg;

while (keepRunning) {
int serverport = tc->serverport;

int sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1) {
perror("Can't allocate sockfd");
continue;
exit(1);
// continue;
}

// socksetup(sockfd, 10);
Expand All @@ -191,16 +191,19 @@ void *receiver(void *arg) {
perror("Bind Error");
close(sockfd);
exit(1);
continue;
// continue;
}

if (listen(sockfd, serverport) == -1) {
perror("Listen Error");
close(sockfd);
exit(1);
continue;
// continue;
}

while (keepRunning) {


socklen_t addrlen = sizeof(clientaddr);
int connfd = accept(sockfd, (struct sockaddr *) &clientaddr, &addrlen);
if (connfd == -1) {
Expand Down Expand Up @@ -403,9 +406,9 @@ void *receiver(void *arg) {
printf("?? %s\n", buffer);
}

close(sockfd);
close(connfd);
}
}
// close(sockfd);
return NULL;
}

Expand Down

0 comments on commit 2e7799c

Please sign in to comment.