Re: Welche Socket Komponente/ Klasse eignet sich gut für Timeouts?



Du kannst unter Windows nur über Events in den Genuß von Timeouts kommen
ein recv() wartet relativ lange, je nach windows interna.

ein :
if(setsockopt(m_sock,SOL_SOCKET,SO_SNDTIMEO,(char *)&timeout,sizeof(int)) ==
SOCKET_ERROR)
return false;
Wirkt nur auf Signale die via WSA erreichbar sind, das sieht dann leider so
aus:

pseudocode:
WSADATA wsaData;
WSAStartup(MAKEWORD(1,1), &wsaData);
HANDLE xEvent;
if( ( xEvent= WSACreateEvent( ) ) == WSA_INVALID_EVENT )
return false;

if( WSAEventSelect( xListenSocket, xEvent, FD_ACCEPT ) == SOCKET_ERROR )

while(1)
{
dwWaitResult = WSAWaitForMultipleEvents( EV_NEVENTS, xEvents,
FALSE,MB_TCP_POOL_TIMEOUT, FALSE );
if( ( dwWaitResult == WAIT_IO_COMPLETION ) || ( dwWaitResult ==
WSA_WAIT_TIMEOUT ) )

else if( dwWaitResult == WSA_WAIT_FAILED )

iRes = WSAEnumNetworkEvents( xListenSocket, xEvent, &xNetworkEvents );

if( xNetworkEvents.lNetworkEvents & FD_ACCEPT )
//anrufer liegt an, also accept

if(xNetworkEvents.lNetworkEvents & FD_READ)
//daten ligen an also
iRes = recv( xClientSocket, &aucTCPBuf[usTCPBufPos],
usTCPFrameBytesLeft, 0 );
}


Konfirm geht es also mit : WSAWaitForMultipleEvents

mann kann auch einen PollThread nehmen der ruft ständig
recv auf, und hängt in dessen timeout sehr lange, sollte
recv jedoch zurückkommen mit daten, wird ein callback
ausgelößt, so handhabe ich den Tanz.

grüße
Karsten Schulz



"Andrea Müller" <xyddvz@xxxxxxxx> schrieb im Newsbeitrag
news:%23UPVfXHrIHA.3420@xxxxxxxxxxxxxxxxxxxxxxx
Hallo,

ich möchte folgendes machen

MFC, C++ ----Socket --- Server

Client ----- Server

Frage: Welche Socket Komponente eignet sich gut für Timeouts?
Ich muss den Timeout mit bekommen.
Mit CAsynSocket gibt es nichts.

Grüße Andrea



.



Relevant Pages

  • Re: Should COBOL be lockedUP for good?...
    ... Windows had demonstrated that if a client ... I don't think that 'Timeouts' are sensible. ... why I would want to lock a record for some hours, ...
    (comp.lang.cobol)
  • Connection timeout to Windows XP Remote Desktop
    ... When we connect to Remote Desktop on Windows XP SP1 and SP2 we sometimes get ... timeouts during the login procedure. ... after which the connection is terminated. ... for instance the amount of memory used by the loggedon user is determining ...
    (microsoft.public.windowsxp.work_remotely)
  • Re: Antwortzeit bei Anwahl eines Verzeichnisses im Netzwerk
    ... wenn Nein, geht es ca. 25 Sekunden bis ich eine Antwort von Windows bekomme. ... wenn ich diese Abfrage mehrmals schnell hintereinander mache, ... Das sind die eingestellten Timeouts von Windows. ... wenn sich der Rechner eine bestimmte Zeit lang gar nicht meldet bzw. wenn die erwarteten Antworten nach einer gewissen Zeit nicht eingetroffen sind. ...
    (microsoft.public.de.vb)
  • Re: GNAT.Sockets: Timeval_Duration is in milliseconds?
    ... So if you are using Windows, Microsoft's decision to screw things up ... I suppose we have to report this as a bug in GNAT though it would be ... Personally I've never used timeouts -- I've used selectand waited ... Sets with only one socket seems to be overcomplication, ...
    (comp.lang.ada)

Loading