Cout schreibt nicht!
Verfasst: Mo Feb 11, 2013 9:14 pm
Hallo Leute,
ich weiß nicht, was mein Problem ist... und bitte um Rat.
Also, ich schreibe eine Server/Client Anwendung. Und das Problem liegt bei dem Server:
Hier ist die Main Funktion (Da stimmt alles):
Und hier, jetzt kommt das merkwürdige Zeug!!!
Dieser Code hiner funktioniert!:
abeerr, so bald ich was anderes mache, außer req auszugeben kommt nichts: (sogar bei string::length() )
Wisst Ihr vielleicht, was da los ist? :/
ich weiß nicht, was mein Problem ist... und bitte um Rat.
Also, ich schreibe eine Server/Client Anwendung. Und das Problem liegt bei dem Server:
Hier ist die Main Funktion (Da stimmt alles):
Code: Alles auswählen
int main()
{
Socket sock1;
sock1.create();
sock1.bind( makeInt(sInfo.serverPort) );
sock1.listen();
while (true)
{
Socket* tmp_sock = new Socket();
sock1.accept( *tmp_sock );
pthread_t b;
pthread_create(&b, NULL, newCommand, (void*) tmp_sock);
}
return 0;
}
Dieser Code hiner funktioniert!:
Code: Alles auswählen
void* newCommand(void* p)
{
pthread_detach(pthread_self());
Socket* sock = (Socket*) p;
string req;
sock->setTimeout(5);
sock->recv (req);
cout << req;
delete sock;
return NULL;
}
Code: Alles auswählen
void* newCommand(void* p)
{
pthread_detach(pthread_self());
Socket* sock = (Socket*) p;
string req;
sock->setTimeout(5);
sock->recv (req);
cout << req.length();
delete sock;
return NULL;
}