I am creating an asynchronous chat application in C. I created two threads, one for receiving and another one for sending as follows.
void* send() { ... } void* receive() { ... } main() { .. inid = pthread_create(&incoming,NULL,receive,"Incoming thread"); outid= pthread_create(&outgoing,NULL,send,"Outgoing thread"); .. pthread_join(incoming,NULL); pthread_join(outgoing,NULL); .. }
What the problem is, the send and receive functions are called only once and the program terminates. I want both the threads to run forever till the user wishes to exit ( the condition to check for exit is defined in the send function). How to solve this?