I'm wayyyy new to this and so am wondering if you might be able to help. We've just finished a project in PHP which includes a large number of functions like the one below - which fire XML to an external server through a POST request and we've been told
that there needs to be a migration of the code to .NET within a matter of days! I've never used .NET before and so would love any suggestions on getting a .NET server up and running internally and, more importantly, how you would look at porting code like
that below:
Many thanks - hopefully I can become a .NET guru someday!
krisp
0 Points
1 Post
Getting Started - Fsockopen equivalents
Apr 06, 2007 03:39 PM|LINK
Hey guys,
I'm wayyyy new to this and so am wondering if you might be able to help. We've just finished a project in PHP which includes a large number of functions like the one below - which fire XML to an external server through a POST request and we've been told that there needs to be a migration of the code to .NET within a matter of days! I've never used .NET before and so would love any suggestions on getting a .NET server up and running internally and, more importantly, how you would look at porting code like that below:
Many thanks - hopefully I can become a .NET guru someday!
Cheers
function info($host,$servlet="XMLAPI",$port=80,$time_out=20){ $sock = fsockopen ($host, $port, $errno, $errstr, $time_out); // open socket on port 80 w/ timeout of 20 $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <Envelope> <Body> Some XML.... </Body> </Envelope>"; $data = "xml=" . $xml; if (!$sock) { print("Could not connect to host:". $errno . $errstr); return (false); } $size = strlen ($data); fputs ($sock, "POST /servlet/" . $servlet . " HTTP/1.1\n"); fputs ($sock, "Host: " . $host . "\n"); fputs ($sock, "Content-type: application/x-www-form-urlencoded\n"); fputs ($sock, "Content-length: " . $size . "\n"); fputs ($sock, "Connection: close\n\n"); fputs ($sock, $data); $buffer = ""; while (!feof ($sock)) { $buffer .= fgets ($sock); } // print ($buffer); fclose ($sock); return ($buffer); }pickyh3d
Star
9696 Points
1955 Posts
Re: Getting Started - Fsockopen equivalents
Apr 13, 2007 05:54 AM|LINK
deepak.vasud...
Contributor
2488 Points
622 Posts
Re: Getting Started - Fsockopen equivalents
Apr 17, 2007 09:53 PM|LINK
Deepak Vasudevan
http://www.lavanyadeepak.tk/
-------
foyzulkarim
Member
9 Points
6 Posts
Re: Getting Started - Fsockopen equivalents
Jul 12, 2011 06:05 AM|LINK
Hi. Did you find the solution? If yes, could you please post the asp.net/C# code in here?
THanks.
The Databiz Software Limited
Software Engineer (.NET Framework)
Team Lead (Mobile Platform)
Dhaka, Bangladesh
vmillasp
Member
626 Points
154 Posts
Re: Getting Started - Fsockopen equivalents
Aug 13, 2011 07:16 PM|LINK
search for this:
System.Net.Sockets.TcpClient