Jump to content
Carlos Barros

[C] Webrequest

Recommended Posts

Carlos Barros

Boa tarde,

Eu gostaria de saber como fazer um WebRequest em C.

por exemplo em C#:

		 ASCIIEncoding enconding = new ASCIIEncoding();
		 String postData = "ip=" + ip + "&name=" + name;
		 byte[] data = enconding.GetBytes(postData);
		 WebRequest request = WebRequest.Create("http://localhost/insert.php");
		 request.Method = "POST";
		 request.ContentType = "application/x-www-form-urlencoded";
		 request.ContentLength = data.Length;
		 Stream stream = request.GetRequestStream();
		 stream.Write(data, 0, data.Length);
		 WebResponse response = request.GetResponse();
		 stream = response.GetResponseStream();
		 StreamReader sr = new StreamReader(stream);

PS: Eu gostaria de saber como fazer em C e NÃO C#.


Edited by Carlos Barros

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.