private byte[] ReadFully(Socket p_connection)
{
Socket connection = p_connection;
byte[] buffer = new byte[connection.ReceiveBufferSize];
int received = connection.Receive(buffer);
Array.Resize(ref buffer, received);
return buffer;
}
Refactorings
No refactoring yet !
rikkus
March 21, 2009, March 21, 2009 16:28, permalink
If you want to perform an HTTP request, you should use WebRequest:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx
Your code is incorrect because it claims to 'read fully' but may, even if there is no error, return less than the 'full' data.
This method will read HTTP requests, is this the best way to read a network recieve stream?