Add client_sockid to thread argument

This commit is contained in:
flyingscorpio@clevo 2022-10-21 11:17:25 +02:00
parent e0ea0473b5
commit d73ea75c69

View file

@ -73,11 +73,11 @@ int main(void) {
} else {
printf("received connection from %s\n", ip4tostring(ntohl(client_socket.sin_addr.s_addr)));
if (pthread_create(&clientsender, NULL, ClientSender, NULL) != 0) {
if (pthread_create(&clientsender, NULL, ClientSender, &client_sockid) != 0) {
fprintf(stderr, "pthread_create: error for ClientSender\n");
exit(EXIT_FAILURE);
}
if (pthread_create(&clientlistener, NULL, ClientListener, NULL) != 0) {
if (pthread_create(&clientlistener, NULL, ClientListener, &client_sockid) != 0) {
fprintf(stderr, "pthread_create: error for ClientSender\n");
exit(EXIT_FAILURE);
}
@ -97,6 +97,7 @@ void *Dispatcher(void *arg) {
/* Thread, listens for incoming messages */
void *ClientListener(void *arg) {
int client_sockid = *((int*) arg);
char buf[BUF_LEN];
int n = 0;
@ -116,6 +117,8 @@ void *ClientListener(void *arg) {
/* Thread, sends messages to the client */
void *ClientSender(void *arg) {
int client_sockid = *((int*) arg);
pthread_exit(0);
}