Add client_sockid to thread argument
This commit is contained in:
parent
e0ea0473b5
commit
d73ea75c69
1 changed files with 5 additions and 2 deletions
|
@ -73,11 +73,11 @@ int main(void) {
|
||||||
} else {
|
} else {
|
||||||
printf("received connection from %s\n", ip4tostring(ntohl(client_socket.sin_addr.s_addr)));
|
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");
|
fprintf(stderr, "pthread_create: error for ClientSender\n");
|
||||||
exit(EXIT_FAILURE);
|
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");
|
fprintf(stderr, "pthread_create: error for ClientSender\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ void *Dispatcher(void *arg) {
|
||||||
|
|
||||||
/* Thread, listens for incoming messages */
|
/* Thread, listens for incoming messages */
|
||||||
void *ClientListener(void *arg) {
|
void *ClientListener(void *arg) {
|
||||||
|
int client_sockid = *((int*) arg);
|
||||||
char buf[BUF_LEN];
|
char buf[BUF_LEN];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
|
||||||
|
@ -116,6 +117,8 @@ void *ClientListener(void *arg) {
|
||||||
|
|
||||||
/* Thread, sends messages to the client */
|
/* Thread, sends messages to the client */
|
||||||
void *ClientSender(void *arg) {
|
void *ClientSender(void *arg) {
|
||||||
|
int client_sockid = *((int*) arg);
|
||||||
|
|
||||||
pthread_exit(0);
|
pthread_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue