diff --git a/netwerk/test/TestSocketTransport.cpp b/netwerk/test/TestSocketTransport.cpp index bef6beb8f93..3e2d9dc41ce 100644 --- a/netwerk/test/TestSocketTransport.cpp +++ b/netwerk/test/TestSocketTransport.cpp @@ -18,7 +18,7 @@ #include #ifdef WIN32 -#define USE_TIMERS // Only use nsITimer on Windows (for now...) +//#define USE_TIMERS // Only use nsITimer on Windows (for now...) #include #endif @@ -304,21 +304,15 @@ TestConnection::Run(void) } Pump_PLEvents(); } -/* - while (NS_SUCCEEDED(rv)) { - rv = WriteBuffer(); + else { + while (NS_SUCCEEDED(rv)) { + rv = WriteBuffer(); - if (NS_SUCCEEDED(rv)) { - rv = ReadBuffer(); - } - - if (mBufferChar == 'z') { - mBufferChar = 'a'; - } else { - mBufferChar++; + if (NS_SUCCEEDED(rv)) { + rv = ReadBuffer(); + } } } -*/ } printf("Transport thread exiting...\n"); @@ -376,6 +370,7 @@ nsresult TestConnection::WriteBuffer(void) // else if (mOutStream) { rv = mOutStream->Write(buffer, size, &bytesWritten); + NS_ASSERTION(size == bytesWritten, "Not enough was written..."); } PR_Free(buffer); } else { @@ -400,8 +395,13 @@ nsresult TestConnection::ReadBuffer(void) buffer = (char*)PR_Malloc(mBufferLength + 4); if (buffer) { - rv = mInStream->Read(buffer, mBufferLength+2, &bytesRead); + rv = mInStream->Read(buffer, mBufferLength, &bytesRead); + if (NS_SUCCEEDED(rv)) { + buffer[bytesRead] = '\0'; + printf("TestConnection::ReadBuffer. Read %d bytes\n", bytesRead); + puts(buffer); + } PR_Free(buffer); } } @@ -504,13 +504,21 @@ main(int argc, char* argv[]) /// return -1; /// } - char* hostName; - int port = 80; + PRBool bIsAsync = PR_TRUE; + char* hostName = nsnull; + int i; - if (argc < 2) { + for (i=1; iGetThreadEventQueue(PR_CurrentThread(), &gEventQ); - int i; - // // Create the connections and threads... // for (i=0; i