yccheok
December 9th, 2002, 04:30 AM
i had build a light weighted http server and recently realize that there is some bugs inside.
in my constructor, i initialize the TcpListener and the thread for receiving incoming request as follow:
----------------------------------
myListener = new TcpListener(port);
myListener.Start();
//start the thread which calls the method 'StartListen'
myThread = new Thread(new ThreadStart(StartListen));
myThread.Start() ;
----------------------------------
in my StartListen
----------------------------------
while(isRunnable)
{
//Accept a new connection
Socket mySocket = myListener.AcceptSocket() ;
if(mySocket.Connected)
{
//make a byte array and receive data from the client
Byte[] bReceive = new Byte[1024] ;
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
// rest of the code goes here
----------------------------------
sometimes, when i use a web broswer making an HTTP/GET request, my web broswer takes 5 minutes to download the contents from the computer that run light weighted server(LWS) and still get no responde. it seems that it can establish a TCP/IP connection to the LWS but get no response from the LWS.
finally, i realize that LWS will halt at the line.
-----------------------------------
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
-----------------------------------
this happen "sometimes". where "sometimes" LWS works fine and "sometimes" LWS dont
can anyone point me out how can i solve this problem? thank you in advance.
regards
yccheok
in my constructor, i initialize the TcpListener and the thread for receiving incoming request as follow:
----------------------------------
myListener = new TcpListener(port);
myListener.Start();
//start the thread which calls the method 'StartListen'
myThread = new Thread(new ThreadStart(StartListen));
myThread.Start() ;
----------------------------------
in my StartListen
----------------------------------
while(isRunnable)
{
//Accept a new connection
Socket mySocket = myListener.AcceptSocket() ;
if(mySocket.Connected)
{
//make a byte array and receive data from the client
Byte[] bReceive = new Byte[1024] ;
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
// rest of the code goes here
----------------------------------
sometimes, when i use a web broswer making an HTTP/GET request, my web broswer takes 5 minutes to download the contents from the computer that run light weighted server(LWS) and still get no responde. it seems that it can establish a TCP/IP connection to the LWS but get no response from the LWS.
finally, i realize that LWS will halt at the line.
-----------------------------------
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
-----------------------------------
this happen "sometimes". where "sometimes" LWS works fine and "sometimes" LWS dont
can anyone point me out how can i solve this problem? thank you in advance.
regards
yccheok