ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Iam working on an application which requires sending request over n/w to server and receiving responses from the server. I have a seperate user defined function in which i create a socket and all other stuff(bind , send to ,recvfrom), the socket i have created is a datagram , nonblocking socket i also have created a thread which will be pointing to a function which runs an infinite loop and keeps on doing the select() function on the socket to read data from the server if any received in the socket. I also have another user defined function in which i close the socket. My requirement is that when the control enters this function in which i close the socket i need to signal the function which is being pointed by the thread so that it can exit the infinite loop. I tried a google but could not find any solution. If anyone has worked on these lines or have any idea abt how this cud be done i request ur goodselves to help me in this problem
In general, I'd suggest setting a global variable.
In this case, why not use a pipe to signal the thread?
Since you're already blocking on "select()" (a good choice, rather than polling, BTW!), you might want to open a dummy file (e.g. a pipe), add that pipe to your "select()" FD_SET list, and then have the thread that closes the socket "signal" the reader thread by writing to the pipe. Voila!
I don't think there's any way to use a true "signal" (e.g. SIGUSER) here...