Hi,
very simple example(maybe wrong one ;) how to recieve file could be
void Jabber::handleFTSOCKS5Bytestream( SOCKS5Bytestream* s5b ) {
log("received socks5 bytestream");
m_s5bs.push_back( s5b );
s5b->registerSOCKS5BytestreamDataHandler( this );
if(s5b->connect()) {
log("ok! s5b connected to streamhost");
}
int th_ret = pthread_create( &conn, NULL, rcv_f, (void*)&m_s5bs );
}
and function that is called in thread is
void *rcv_f(void *list){
std::list<SOCKS5Bytestream*> * l = (std::list<SOCKS5Bytestream*> *)
list;
std::list<SOCKS5Bytestream*>::iterator it = l->begin();
for( ; it != l->end(); ++it ){
(*it)->recv(-1);
}
}
so i want this thread to stay in recv method till whole file is
downloaded...but last thing i got in log is
Jan 05 22:12:38 INFO received socks5 bytestream
Jan 05 22:12:38 INFO connecting to xxx.xxx.xxx.xxx ( xxx.xxx.xxx.xxx
:8010)
Jan 05 22:12:38 INFO attempting to negotiate socks5 proxy connection
Jan 05 22:12:38 INFO ok! s5b connected to streamhost
Jan 05 22:12:38 INFO requesting socks5 proxy connection to
2e37a3e2529b1c35697f4f24f26a77e63906c714:0
if i change rcv_f method like this :
void *rcv_f(void *list){
std::list<SOCKS5Bytestream*> * l = (std::list<SOCKS5Bytestream*> *)
list;
std::list<SOCKS5Bytestream*>::iterator it = l->begin();
int a = 100;
for( ; it != l->end(); ++it ){
while (a-- > 0)
(*it)->recv(-1);
}
}
file IS RECEIVED....but after that of course Segmentation fault comes :),
because connection is closed...what could cause that recv is not receiving
files? in example it works fine. But in my application not...
Pls tell me how to solve this situation...maybe I'm doing it completely
wrong :)
Thx a lot..