// Read the HTTP Request Byte[] bReceive = new Byte[MAXBUFFERSIZE]; int i = socket.Receive(bReceive, bReceive.Length, 0); //Convert Byte to String string sBuffer = Encoding.ASCII.GetString(bReceive); // Look for HTTP request iStartPos = sBuffer.IndexOf("HTTP", 1); // Extract the Command without GET_/ at the beginning and _HTTP at the end sRequest = sBuffer.Substring(5, iStartPos - 1 - 5); String answer = handleRequest(sRequest); // Send the response socket.Send(Encoding.UTF8.GetBytes(answer));