|
@@ -113,7 +113,6 @@ SKlient::SKlient( sockaddr_in addresse, SOCKET sock )
|
|
|
upStreamBytes = 0;
|
|
|
sendeKey = 0;
|
|
|
empfangKey = 0;
|
|
|
- empfangTimeout = 0;
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
@@ -129,19 +128,15 @@ SKlient::~SKlient()
|
|
|
// nicht constant
|
|
|
void SKlient::setEmpfangTimeout( int miliseconds ) // Setzt ein timeout fürs empfangen von daten
|
|
|
{
|
|
|
- empfangTimeout = miliseconds;
|
|
|
- if( empfangTimeout )
|
|
|
- {
|
|
|
#ifdef WIN32
|
|
|
- DWORD timeout = miliseconds;
|
|
|
- setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof timeout );
|
|
|
+ DWORD timeout = miliseconds;
|
|
|
+ setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof timeout );
|
|
|
#else
|
|
|
- struct timeval tv;
|
|
|
- tv.tv_sec = miliseconds / 1000;
|
|
|
- tv.tv_usec = (miliseconds % 1000) * 1000;
|
|
|
- setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv );
|
|
|
+ struct timeval tv;
|
|
|
+ tv.tv_sec = miliseconds / 1000;
|
|
|
+ tv.tv_usec = (miliseconds % 1000) * 1000;
|
|
|
+ setsockopt( sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv );
|
|
|
#endif
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void SKlient::setSendeKeyZ( Encryption::Key* key ) // Setzt den Key fürs Senden
|
|
@@ -200,7 +195,7 @@ bool SKlient::getNachricht( char* nachricht, int len ) // empf
|
|
|
int ll = 0;
|
|
|
while( len > 0 )
|
|
|
{
|
|
|
- int l = (int)recv( sock, nachricht + ll, len, empfangTimeout ? 0 : MSG_WAITALL );
|
|
|
+ int l = (int)recv( sock, nachricht + ll, len, MSG_WAITALL );
|
|
|
if( l <= 0 )
|
|
|
return 0; // Fehler
|
|
|
len -= l;
|
|
@@ -243,7 +238,7 @@ bool SKlient::getNachrichtEncrypted( char* nachricht, int len ) // empf
|
|
|
int ll = 0;
|
|
|
while( len > 0 )
|
|
|
{
|
|
|
- int l = (int)recv( sock, nachricht + ll, len, empfangTimeout ? 0 : MSG_WAITALL );
|
|
|
+ int l = (int)recv( sock, nachricht + ll, len, MSG_WAITALL );
|
|
|
if( l <= 0 )
|
|
|
return 0; // Fehler
|
|
|
len -= l;
|
|
@@ -335,7 +330,7 @@ bool SSLErrorCheck( __int64 result, const char* action )
|
|
|
bool SKlient::waitForNextMessage() const // wartet bis es etwas zu empfangen gibt
|
|
|
{
|
|
|
char c;
|
|
|
- int l = (int)recv( sock, &c, 1, (empfangTimeout ? 0 : MSG_WAITALL) | MSG_PEEK );
|
|
|
+ int l = (int)recv( sock, &c, 1, MSG_WAITALL | MSG_PEEK );
|
|
|
if( l <= 0 )
|
|
|
return 0; // Fehler
|
|
|
return 1;
|
|
@@ -504,7 +499,6 @@ SSLSKlient::SSLSKlient( sockaddr_in client, SSL* ssl, SOCKET s )
|
|
|
this->ssl = ssl;
|
|
|
downStreamBytes = 0;
|
|
|
upStreamBytes = 0;
|
|
|
- empfangTimeout = 0;
|
|
|
}
|
|
|
|
|
|
// Destruktor
|
|
@@ -519,19 +513,15 @@ SSLSKlient::~SSLSKlient()
|
|
|
// nicht constant
|
|
|
void SSLSKlient::setEmpfangTimeout( int miliseconds ) // Setzt ein timeout fürs empfangen von daten
|
|
|
{
|
|
|
- empfangTimeout = miliseconds;
|
|
|
- if( empfangTimeout )
|
|
|
- {
|
|
|
#ifdef WIN32
|
|
|
- DWORD timeout = miliseconds;
|
|
|
- setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof timeout );
|
|
|
+ DWORD timeout = miliseconds;
|
|
|
+ setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, (const char*)&timeout, sizeof timeout );
|
|
|
#else
|
|
|
- struct timeval tv;
|
|
|
- tv.tv_sec = miliseconds / 1000;
|
|
|
- tv.tv_usec = (miliseconds % 1000) * 1000;
|
|
|
- setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv );
|
|
|
+ struct timeval tv;
|
|
|
+ tv.tv_sec = miliseconds / 1000;
|
|
|
+ tv.tv_usec = (miliseconds % 1000) * 1000;
|
|
|
+ setsockopt( s, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv );
|
|
|
#endif
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
bool SSLSKlient::sende( const char* nachricht, int len ) // sendet zum Klient
|