Getting Started - Fsockopen equivalentshttp://forums.asp.net/t/1096072.aspx/1?Getting+Started+Fsockopen+equivalentsSat, 13 Aug 2011 19:16:12 -040010960721654934http://forums.asp.net/p/1096072/1654934.aspx/1?Getting+Started+Fsockopen+equivalentsGetting Started - Fsockopen equivalents <p>Hey guys,</p> <p>I'm wayyyy new to this and so am wondering if you might be able to help.&nbsp; 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!&nbsp; 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:</p> <p>&nbsp;</p> <p>Many thanks - hopefully I can become a .NET guru someday!</p> <p>&nbsp;</p> <p>Cheers<br> &nbsp;</p> <pre class="prettyprint">function info($host,$servlet=&quot;XMLAPI&quot;,$port=80,$time_out=20){ $sock = fsockopen ($host, $port, $errno, $errstr, $time_out); // open socket on port 80 w/ timeout of 20 $xml = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;UTF-8\&quot;?&gt; &lt;Envelope&gt; &lt;Body&gt; Some XML.... &lt;/Body&gt; &lt;/Envelope&gt;&quot;; $data = &quot;xml=&quot; . $xml; if (!$sock) { print(&quot;Could not connect to host:&quot;. $errno . $errstr); return (false); } $size = strlen ($data); fputs ($sock, &quot;POST /servlet/&quot; . $servlet . &quot; HTTP/1.1\n&quot;); fputs ($sock, &quot;Host: &quot; . $host . &quot;\n&quot;); fputs ($sock, &quot;Content-type: application/x-www-form-urlencoded\n&quot;); fputs ($sock, &quot;Content-length: &quot; . $size . &quot;\n&quot;); fputs ($sock, &quot;Connection: close\n\n&quot;); fputs ($sock, $data); $buffer = &quot;&quot;; while (!feof ($sock)) { $buffer .= fgets ($sock); } // print ($buffer); fclose ($sock); return ($buffer); }</pre>&nbsp;<br> 2007-04-06T15:39:37-04:001664099http://forums.asp.net/p/1096072/1664099.aspx/1?Re+Getting+Started+Fsockopen+equivalentsRe: Getting Started - Fsockopen equivalents <a href="http://www.netomatix.com/HttpPostData.aspx">http://www.netomatix.com/HttpPostData.aspx</a> 2007-04-13T05:54:50-04:001669900http://forums.asp.net/p/1096072/1669900.aspx/1?Re+Getting+Started+Fsockopen+equivalentsRe: Getting Started - Fsockopen equivalents <a href="http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.aspx">http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.aspx</a> 2007-04-17T21:53:16-04:004502400http://forums.asp.net/p/1096072/4502400.aspx/1?Re+Getting+Started+Fsockopen+equivalentsRe: Getting Started - Fsockopen equivalents <p>Hi. Did you find the solution? If yes, could you please post the asp.net/C# code in here?</p> <p>THanks.&nbsp;</p> 2011-07-12T06:05:05-04:004552796http://forums.asp.net/p/1096072/4552796.aspx/1?Re+Getting+Started+Fsockopen+equivalentsRe: Getting Started - Fsockopen equivalents <p>search for this:</p> <p>System.Net.Sockets.TcpClient</p> 2011-08-13T19:16:12-04:00