recv() macht Probleme
-
Hallo,
bin grade dabei en kleinen IRC Client zu schreiben.
Aber recv() macht ab und zu ein paar Probleme.
Und zwar liefert recv() manchmal -1 und manchmal klappt es.
An was könnte das liegen?
-
WSAGetLastError
-
Erhalte manchmal die Fehlercode's:
WSAENOTSOCK 10038 Socket operation on nonsocket. An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.WSAECONNRESET 10054 Connection reset by peer. An existing connection was forcibly closed by the remote host. This normally results if the peer application on the remote host is suddenly stopped, the host is rebooted, the host or remote network interface is disabled, or the remote host uses a hard close (see setsockopt for more information on the SO_LINGER option on the remote socket). This error may also result if a connection was broken due to keep-alive activity detecting a failure while one or more operations are in progress. Operations that were in progress fail with WSAENETRESET. Subsequent operations fail with WSAECONNRESET.Den 10054 Fehlercode verstehe ich ja,aber den 10038 nicht weil manchmal gehts halt und manchmal nicht
-
10038 kann z.B. kommen, wenn Du ein schon geschlossenes Socket verwendest.
Simon
-
Ja ich habe also eine for Schleife und beim ersten Durchlauf der for Schleife gibt mir recv manchmal -1 zurück,manchmal auch nicht.
Verstehe einfach nicht warum es manchmal geht und warum mal nicht.
-
So sieht mein Aufruf von recv() aus:
err = recv(socket,puffer,1024,0);Doch puffer ist immer mit 1036 Zeichen gefüllt wenn Fehlercode 10036 kommt.
Kanns daran liegen?
-
Wenn es zum Fehlercode 10036 kommt dann sind komischer weiße immer 12 bytes mehr im buffer als ich bei recv als len Parameter angab.
-
lol wenn es zu einem fehler kommt ist der inhalt des puffers undefiniert
-
Doch:
char puffer[1024];
-

-
Unnötiger Post.
-.-