Hi,
I'm new on android app development, now creating client-server system, and both of them are made from scratch. Let me ask you a question.
I'm trying to send message from my client (android 2.2.1) to my server (C#, windows7) with GET method. Both of them look like working well: the client got 200 from Twitter, and the server got message when accessed from web browser.
However, the client throws IO Exception and the server gets nothing when tried with them (even with fire wall unenabled). Anyone know why?
thanks...konoka
client(android):
server(C#):
I'm new on android app development, now creating client-server system, and both of them are made from scratch. Let me ask you a question.
I'm trying to send message from my client (android 2.2.1) to my server (C#, windows7) with GET method. Both of them look like working well: the client got 200 from Twitter, and the server got message when accessed from web browser.
However, the client throws IO Exception and the server gets nothing when tried with them (even with fire wall unenabled). Anyone know why?
thanks...konoka
client(android):
Code:
public void sendMessage(String strQuery){
HttpGet httpget = new HttpGet("http://192.168.32.240:5000/"+strQuery);
//HttpGet httpget = new HttpGet("http://twitter.com/"); //test
DefaultHttpClient client = new DefaultHttpClient();
try {
HttpResponse httpResponse = client.execute(httpget);
this.showMessage(Integer.toString(httpResponse.getStatusLine().getStatusCode()));
client.getConnectionManager().shutdown();
} catch (ClientProtocolException e) {
this.showMessage("bad protocol");
} catch (IOException e) {
this.showMessage("IOException");
}
}
server(C#):
Code:
void startServer()
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add("http://*:5000");
listener.Start
HttpListenerContext context = listener.GetContext();
Console.WriteLine(con.Request.RawUrl);
byte[] buffer = Encoding.Unicode.GetBytes("200");
context.Response.OutputStream.Write(buffer, 0, buffer.Length);
}