<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Hello,</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> I try to use HttpWebRequest
in c#/Mono on my nokia 770 (in fact, I want to use Web Services).<br> <br>The first part of the below
program which use TcpClient() works very well: I can get a page from a distant
server.<br>But with the second part,
which use HttpWebRequest, fails with a 'time out" exception at the
request.GetResponse() :<br> …<br>Unhandled Exception:
System.Net.WebException: The request timed out<br>in <0x001b8>
System.Net.HttpWebRequest:EndGetResponse (IAsyncResult asyncResult)<br>in <0x0007f> System.Net.HttpWebRequest:GetResponse
()<br>in <0x003df>
Http.Requete:Main (System.String[] args)<br>/ $</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> I installed the
mono-nokia_1.1.13-1_arm.deb package and copied the 'machine.config' file to the
'/var/lib/install/usr/etc/mono/1.0/' directory.<br>This program works very well
on windows with mono-1.1.13. <br></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Is it a bug? Did i miss
something? Does somebody have any idea?</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Thanks,</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Marc. <br></span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">// ------ httpConnectTest.cs
------------------------<br>using System;<br>using System.IO;<br>using System.Net;<br>using System.Net.Sockets; </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">namespace NetworkTest<br>{<br>
class Request<br>
{<br>
static void Main(string[] args)<br>
{<br>
try<br>
{<br>
//------- First part with TcpClient.GetStream() ip connection<br>
String server = "<a href="http://192.168.0.2">192.168.0.2</a>";<br>
Int32 port = 80;<br>
String message = "GET / HTTP/1.0\r\r\n\n";<br>
</span></font><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;">TcpClient client = new TcpClient(server, port);<br>
</span></font><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">Byte[] data =
System.Text.Encoding.ASCII.GetBytes(message); <br>
NetworkStream stream = client.GetStream();<br>
stream.Write(data, 0, data.Length);<br>
// Receive the TcpServer.response.<br>
string returndata="";<br>
byte[]
octetsRecus;<br>
string result="";<br>
do {<br>
octetsRecus= new byte[client.ReceiveBufferSize];<br>
stream.Read(octetsRecus, 0, (int) client.ReceiveBufferSize);<br>
returndata = System.Text.Encoding.ASCII.GetString(octetsRecus);<br>
result+=returndata;<br>
} while (octetsRecus[0]!=0);<br>
Console.WriteLine("Received: \n {0}",result); <br>
client.Close(); <br>
// ------ Second part with
HttpWebRequest.GetResponse() ip connection<br>
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("<a href="http://192.168.0.2:80">http://192.168.0.2:80</a>");</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">
Console.WriteLine ("\nExecute the request...");<br>
HttpWebResponse response = (HttpWebResponse) request.GetResponse(); //<--
here is the 'time out' exception<br>
Console.WriteLine ("Content length is {0}", response.ContentLength);<br>
StreamReader Sr = new StreamReader(response.GetResponseStream());<br>
String result1 = Sr.ReadToEnd();<br>
Console.WriteLine ("Received: \n {0}",result1);<br>
Sr.Close();<br>
}
catch (Exception e) </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB">
{<br>
Console.WriteLine("Exception: {0}", e);<br>
}<br>
Console.WriteLine("\n Press Enter to continue...");<br>
Console.Read();<br>
}<br> }<br>}<br>// end of program</span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>
<p class="MsoNormal"><font face="Arial" size="2"><span style="font-size: 10pt; font-family: Arial;" lang="EN-GB"> </span></font></p>