Reputation: 2578
I would like to know two things about the following code:
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
Here are my two questions: - What is exactly a stream? - The line myWriter.Write sends an Http Packet with the post information or to do that i have to use a method of HttpWebRequest class?
Upvotes: 1
Views: 185
Reputation: 1
http://msdn.microsoft.com/fr-fr/library/system.net.webresponse.getresponsestream%28VS.80%29.aspx
Upvotes: 0
Reputation: 31848
As already stated a Stream is the usual .NET equivalent of a buffer. It's also almost always used when doing any sort of IO, be it files, pipes, network. Usually to work with a stream you use either StreamReader or StreamWriter.
Your method should be sending a packet correctly. To read a response you would do a similar operation with GetResponseStream
.
Upvotes: 1
Reputation: 9403
The stream in this case is a buffer which will be sent over network. This buffer is sent when you use GetResponse
function
Upvotes: 1
Reputation: 6102
A stream in .NET can be regarded as kind of a buffer.
It is used in file/http/memory IO
Upvotes: 1