Originally Posted by
christop
It could be many things, like how you are multiplexing between reading from each socket, but we would need to see your code before we can say for sure.
// More stuff behind here to fetch browser response which should only be a header.
Code:
while ( true )
{
MSG = "";
if ( DEBUG1 ) {
counter++;
printf( " - Entering Exchange #%d\n\n", counter );
fprintf( DEBUG_FP, " - Entering Exchange #%d\n\n", counter );
}
FD_1 = GET_FD( SERVER );
FD_2 = GET_FD( CLIENT );
FD_ZERO(&READ_FDS);
FD_SET(FD_1, &READ_FDS);
FD_SET(FD_2, &READ_FDS);
MAX_FD = ( FD_1 > FD_2 ) ? FD_1 : FD_2;
if ( select( MAX_FD+1, &READ_FDS, NULL, NULL, &waitd ) <= 0 )
{
if ( DEBUG1 )
{
printf( "%c[1;91m - ERROR: Could not select...%c[0m\n", 27, 27 );
fprintf( DEBUG_FP, " - ERROR: Could not select...\n" );
}
return true;
}
if ( FD_ISSET ( FD_1, &READ_FDS ) )
{
if ( DEBUG2 )
{
printf ( "\n - The browser wants to talk...\n" );
fprintf ( DEBUG_FP, "\n - The browser wants to talk...\n" );
}
break;
} else {
FD_CLR( FD_1, &READ_FDS ); Not sure if this was pointless...?
}
if ( FD_ISSET ( FD_2, &READ_FDS ) )
{
if ( DEBUG2 )
{
printf( "\n - The web server wants to talk...\n" );
fprintf( DEBUG_FP, "\n - The web server wants to talk...\n" );
}
memset ( message, 0, BUFFER );
if ( RECV ( CLIENT, message, BUFFER) == false )
{
return true;
}
MSG = message;
if ( GZIP_ENCODE == true )
{
DATA += MSG;
}
//we're dealing with the server's body - send it to the browser
if ( DEBUG2 ) {
printf( "\n - Says this (%d):\n\n", (int)MSG.length() );
fprintf( DEBUG_FP, "\n - Says this (%d):\n\n", (int)MSG.length() );
if ( OUTPUT )
{
printf( "%s\n", (char*)MSG.c_str() );
fprintf( DEBUG_FP, "%s\n", (char*)MSG.c_str() );
}
}
if ( !SEND ( SERVER, message ) )
{
break;
}
if ( DEBUG2 )
{
printf( "\n - Wrote to browser...\n\n" );
fprintf( DEBUG_FP, "\n - Wrote to browser...\n\n" );
}
}
else
{
FD_CLR( FD_2, &READ_FDS ); // Same thing here...
}
}
}
Yeap so there it is, its partial, but I'm only concerned with the fd_set which might be the problem, or maybe encoding and how the program handles that, im just not sure.