There is a transient bug in my code which I just can't catch. Could you help please?
The basic idea is this. I have a multithreaded server and two thread pools, the IO pool and Worker pool. The main server thread listens to incoming connections. When it gets one, it dispatches a thread from the IO pool to read the socket. An IO thread reads the socket. If there is data, it invokes a thread from the Worker pool. This thread then finishes off the processing including closing the socket. The code follows.
Before I show the code, let me tell you what's happening when I am testing it. I have a client program which has about 30 threads, each opening a separate socket connection with the server. Each sends a request which the server responds to. Sometimes I have all the threads finish in a zip. Sometimes both the client and the server hangs. And yet at other times, the client gets a connection refused message.
Now the code. I have omitted some of the nitty-gritties, including possibly variable declarations. I'll post them if it's required.
Now the read_socket thread which reads from the sockets.
Finally the worker thread function.
I use the following setup:
Sorry for the “word salad” subject, but I wanted to cast a wide net for help.
I've created an IP (Internet Protocol) server which serves HTTP, SMTP, and FTP requests.
As you probably know, they all require creating a socket, listening on it, accepting connections, and then having a short... (3 Replies)
hai guys,
I'm doing a project in which one server communicates with several clients. How can i do it when i have different port numbers???:confused: (0 Replies)
if i have a server which wants to connect to exactly 5 clients, does that mean i need 5 socket file descriptors and use
listen(socket_fd,1);
for each one
or just do
listen(socket_fd,5)
also whats the second parameter number mean? what happens if i put 0 there?
also if i am connected... (28 Replies)
I am using epoll to manage my network connections. At the client side, the idea is to send the message upon detecting the completion of connect(). I've set up the socket to be nonblocking, then after calling of connect(), I add the socket into the epoll and wait on the event to be detected from... (0 Replies)
Hi all,
How can I get the list of all Threads and the Total count of threads under a particular process ?
Do suggest !!
Awaiting for the replies !!
Thanks
Varun:b: (2 Replies)
I've got a program running using epoll to poll activity on a listening socket. I want to be able to output a message to the terminal when the socket is connected to from the client app. It appears that epoll doesn't throw any events on the connect but only on the socket activity. Is there any... (1 Reply)
I'm looking at http://www.opengroup.org/pubs/online/7908799/xsh/pthread.h.html trying to understand mutexs and semaphores. Windows makes a distinction between the two. Is a mutex and semaphore different in unix land?
Is there a tutorial on threading in unix somewhere?
I'm also looking at... (4 Replies)
Hai,
How cani declare socket and collect the data in a string varialbe.
Since i am new to this i am asking this.
Can we connect multiple port.
Thank you. (6 Replies)
I programmed simple tcp server using nonblocking sockets and epoll.
But I am facing some problems.
1. I can recv from events.data.fd but I can't send any data over
events.data.fd
2. When I make multiple connections at once (say 100) I get segmentation
fault...
What am I doing wrong?
... (1 Reply)