S
Skypea
Guest
Hi! I create a web server in my Windows Forms Application using Socket to receive HTTP GET/POST request. But, I have a problem when reading the request data from client. I use this code to receive/read data from client, it based on the example of this documentation:
Do
bytes = socket.Receive(bytesReceived, bytesReceived.Length, 0)
Loop While bytes > 0
The problem is, if all the data has received, then on the next loop (executing socket.Receive), I got a timeout error (Socket Exception) instead of bytes = 0.
I have tried to surround the bytes = socket.Receive with try-catch, but I think it's not a good solution because it will delay until I got socket exception and I have to read and process the request as quick as possible.
Any solution? my client are using HttpWebRequest to do a request.
Continue reading...
Do
bytes = socket.Receive(bytesReceived, bytesReceived.Length, 0)
Loop While bytes > 0
The problem is, if all the data has received, then on the next loop (executing socket.Receive), I got a timeout error (Socket Exception) instead of bytes = 0.
I have tried to surround the bytes = socket.Receive with try-catch, but I think it's not a good solution because it will delay until I got socket exception and I have to read and process the request as quick as possible.
Any solution? my client are using HttpWebRequest to do a request.
Continue reading...