Re: C++ threads, sockets




"verdverm" <verdverm@xxxxxxxxx> wrote in message
news:1176196710.926318.200210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Apr 4, 7:39 am, "Maxim Yegorushkin" <maxim.yegorush...@xxxxxxxxx>
wrote:
On 4 Apr, 00:38, "verdverm" <verdv...@xxxxxxxxx> wrote:

I havd tried the posix threads with multiple socket clients making
high rate requests and they start hanging (always in socket::recv()
like waiting for incoming data? ), not all at the same time, and not
always all of them.

Do you mean that for each accept()ed connection it creates a thread to
serve the connection?

Not sure if its a thread memory problem or a problem with the TCP
handshake
The threads have access to a global static vector and make ~25 GET
http requests per minute

gcc 4.1 / kernel 2.6.20 / basically most recent stable releases

Thoughts...? recomendatiions, more info...?

Try running it under strace to get more info.

haven't gotten a chance to try anything out, but its more like


create 10 threads

thread func {

Socket s; // and init
s.connect
s.send( "GET ..." ); a .csv file
string data
while( s.recv(buf) )
data+= buf;

process data
write data to disk

}


the idea was to learn about threads and take advantage of the idle
time
while trying to increase the # of GETs per minute



If recv() is hanging, there might be a problem in your GET request. Are you
using HTTP/1.0 or 1.1? You should use 1.0, or else the server will maintain
a persistent connection (i.e., keep the connection open), and recv() will
hang because the connection has not been closed.

Mike


.



Relevant Pages

  • Re: Connecting Out of Process Servers via COM+
    ... connection, and in fact we can only use one connection because of the way ... years ago when I needed a number of clients to share a single serial ... it would create a Dispatcher-Object first and registers ... > This means, altough COM+ would allow parallel requests, the calls would be ...
    (microsoft.public.vb.com)
  • Re: output.c error in multithreaded program
    ... >>I find an access violation windows message and start the JIT debugger to ... > thread will block until the Sleep() expires, ... >>it a good enough approach to handle repeated requests. ... connection. ...
    (microsoft.public.vc.mfc)
  • Slow DNS requests?
    ... I think that the delay is in resolving the DNS requests. ... Guest machines connected via CAT5 to the BEFSR41 run fine. ... As soon as the host name is resolved, performance seems to improve dramatically for that connection. ... It offers one set of entries for "Name Servers" and a different set for "Domain Search". ...
    (comp.os.linux.networking)
  • Re: http pipelining
    ... Oops, sorry, you meant sending requests in parallel, right? ... down a single TCP connection, without waiting for the first response. ... Certainly urllib and urllib2 don't support pipelining. ...
    (comp.lang.python)
  • Re: Slow DNS requests?
    ... I think that the delay is in resolving the DNS requests. ... Guest machines connected via CAT5 to the BEFSR41 run fine. ... As soon as the host name is resolved, performance seems to improve dramatically for that connection. ... your DHCP server will tell your machine what name servers to use. ...
    (comp.os.linux.networking)