You are not logged in.
I have a program which runs multiple threads, each thread opens a listening socket and waits for connections.
For each connection that i accept i do a connect() on a new socket to another host (the program acts as relay between the client and the other host).
This works fine in the first thread, however in the 2nd thread i get a POLLHUP from poll() for my newly connected socket right after connecting it.
In this case it doesnt matter if the first thread has a open connection or not, even ending the first thread doesnt change it.
Is this a problem because of threading in general or did i mess up somewhere? Couldnt find anything usefull on google about this.
Sources: http://www.ivory-tower.de/tcp_relay.tar.gz
Im still learning so excuse me if the code is newbie'sh =P
Last edited by Envil (2008-12-10 20:39:18)
Offline
Hi !
You shouldn't be initializing and then calling connect() on a handle which was returned by accept() because accept() returns handle to opened and initilized socket (if it's != -1) . You're overwriting that valid handle and you're trying to connect to the client. Check this: http://beej.us/guide/bgnet/output/html/ … index.html - it may help you.
Offline
I did not call connect() on the accept socket, as i wrote i initialized a new one for that.
However i already solved this, problem just was that the thread_id was not set correctly and due to that all further threads did not have AF_INET set on their remote sockets.
Offline