TCP einstellung
-
Hi,
Ich versuch in der Winsock-Programmierung den TCP-Timeout einzustellen, jedoch bleibt der Timeout bei einer Sekunde, ich will aber dass es 500 Millisekunden sind. Was ist falsch?:
int tmout = 500; // 500 Millisekunden sock = socket(AF_INET, SOCK_STREAM, 0); setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tmout, sizeof(tmout)); setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tmout, sizeof(tmout));
Viele Grüße
-
Rückgabewert!?
-
jedoch bleibt der Timeout bei einer Sekunde
der standardwert ist definitiv nicht eine Sekunde! was meinst du also damit?
-
The timeout, in milliseconds, for blocking receive calls. The default for this option is zero, which indicates that a receive operation will not time out. If a blocking receive call times out, the connection is in an indeterminate state and should be closed.
If the socket is created using the WSASocket function, then the dwFlags parameter must have the WSA_FLAG_OVERLAPPED attribute set for the timeout to function properly. Otherwise the timeout never takes effect.
-
Lies Dir die Grundlagen durch
http://msdn.microsoft.com/en-us/library/windows/desktop/ms740673%28v=vs.85%29.aspx
Es gibt hier Beispiele und die Api
Alternativ als Einführung in die Netzwerkprogrammierung:
http://www.zotteljedi.de/socket-tipps/Timeout long and prosper!