Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, Does the server in the hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpServer.java work in Android? When I try to use the constructor, HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params) Eclipse says constructor is not defined. Eclipse gives a quick fix to change the constructor as: HttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory) How will I register the handler for my requests in this case? Thanks in advance! On Wednesday, December 19, 2012 2:18:04 PM UTC+2, skink wrote: Archana wrote: Hi, I m implementing threads first. Can I use Basic HTTP server from the link http://hc.apache.org/httpcomponents-core-ga/examples.html ? Can you please let me know the difference between handling blocking requests and blocking IO(as specified in the link). Thanks! after two minute googling I got this: http://www.oracle.com/technetwork/java/socket-140484.html why don't you use Google for a basic socket stuff that has nothing to do with android? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, Does the server in the hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpServer.java work in Android? When I try to use the constructor, HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params) Eclipse says constructor is not defined. Eclipse gives a quick fix to change the constructor as: HttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory) How will I register the handler for my requests in this case? Thanks in advance! On Wednesday, December 19, 2012 2:18:04 PM UTC+2, skink wrote: Archana wrote: Hi, I m implementing threads first. Can I use Basic HTTP server from the link http://hc.apache.org/httpcomponents-core-ga/examples.html ? Can you please let me know the difference between handling blocking requests and blocking IO(as specified in the link). Thanks! after two minute googling I got this: http://www.oracle.com/technetwork/java/socket-140484.html why don't you use Google for a basic socket stuff that has nothing to do with android? pskink you had a working single threaded serverthat started like this: while(true){ socket = serverSocket.accept(); why don't you change it to the multi threaded one? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
The link contains code where a separate thread is started for each request. Can I use it? Can you please explain your comment? Thanks! On Thu, Dec 27, 2012 at 1:33 PM, skink psk...@gmail.com wrote: Archana wrote: Hi, Does the server in the hc.apache.org/httpcomponents-core-ga/httpcore/examples/org/apache/http/examples/ElementalHttpServer.javawork in Android? When I try to use the constructor, HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams params) Eclipse says constructor is not defined. Eclipse gives a quick fix to change the constructor as: HttpService(HttpProcessor proc, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory) How will I register the handler for my requests in this case? Thanks in advance! On Wednesday, December 19, 2012 2:18:04 PM UTC+2, skink wrote: Archana wrote: Hi, I m implementing threads first. Can I use Basic HTTP server from the link http://hc.apache.org/httpcomponents-core-ga/examples.html ? Can you please let me know the difference between handling blocking requests and blocking IO(as specified in the link). Thanks! after two minute googling I got this: http://www.oracle.com/technetwork/java/socket-140484.html why don't you use Google for a basic socket stuff that has nothing to do with android? pskink you had a working single threaded serverthat started like this: while(true){ socket = serverSocket.accept(); why don't you change it to the multi threaded one? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Regards, Archana -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana r wrote: The link contains code where a separate thread is started for each request. Can I use it? yes pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, I m implementing threads first. Can I use Basic HTTP server from the link http://hc.apache.org/httpcomponents-core-ga/examples.html ? Can you please let me know the difference between handling blocking requests and blocking IO(as specified in the link). Thanks! On Tuesday, December 18, 2012 7:09:59 PM UTC+2, skink wrote: Archana wrote: I read using threads causes overhead, performance and scalability issues. It is efficient if there are a limited number of clients. So I think using java.nio would be the best option. Any example that shows handling the HTTP methods without blocking. how many concurrent requests do you expect? 10, 100, 1000, more? if ten or so its no problem, if more you probably should change the platform pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, I m implementing threads first. Can I use Basic HTTP server from the link http://hc.apache.org/httpcomponents-core-ga/examples.html ? Can you please let me know the difference between handling blocking requests and blocking IO(as specified in the link). Thanks! after two minute googling I got this: http://www.oracle.com/technetwork/java/socket-140484.html why don't you use Google for a basic socket stuff that has nothing to do with android? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
I read using threads causes overhead, performance and scalability issues. It is efficient if there are a limited number of clients. So I think using java.nio would be the best option. Any example that shows handling the HTTP methods without blocking. On Monday, December 17, 2012 7:06:00 PM UTC+2, Kristopher Micinski wrote: On Mon, Dec 17, 2012 at 6:35 AM, Archana ramalinga...@gmail.comjavascript: wrote: Hi, Is it like having separate thread for each request(GET/POST/DELETE) ? Can you please explain? I was also thinking of AsyncTask, message queue or multithreading. Thanks! Basically, those are all equivalent... AsyncTask is using a thread pool under the hood, a message queue will probably be a key step in using multi threading also. One nice thing about these requests is that handling them typically doesn't involve much cross communication between requests: as long as you can serialize on transactions through shared pieces of the app. E.g., if you have a GET request which grabs some information from a database, you can spawn a thread to get the info from the different tables and amalgamate it. If you subsequently get a DELETE you can delete all the required information. One key thing here will be to think about transactions if you have more complex SQL statements. (Single queries are implicitly wrapped in transactions anyway, by sqlite, iirc...) There is nothing specific to Android here though, kris -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Maybe you should try to use threads first and see what happens... :-) It's funny you mention that you don't want to use this approach because it has overhead, performance and scalability issues: running a server on Android has those issues! If you are really concerned about performance and scalability, you should be using GCM, not writing your own server: servers were never meant to run on Android anyway. And you won't be able to scale it: any carrier will probably block ports anyway. Kris On Tue, Dec 18, 2012 at 8:40 AM, Archana ramalingam.arch...@gmail.com wrote: I read using threads causes overhead, performance and scalability issues. It is efficient if there are a limited number of clients. So I think using java.nio would be the best option. Any example that shows handling the HTTP methods without blocking. On Monday, December 17, 2012 7:06:00 PM UTC+2, Kristopher Micinski wrote: On Mon, Dec 17, 2012 at 6:35 AM, Archana ramalinga...@gmail.com wrote: Hi, Is it like having separate thread for each request(GET/POST/DELETE) ? Can you please explain? I was also thinking of AsyncTask, message queue or multithreading. Thanks! Basically, those are all equivalent... AsyncTask is using a thread pool under the hood, a message queue will probably be a key step in using multi threading also. One nice thing about these requests is that handling them typically doesn't involve much cross communication between requests: as long as you can serialize on transactions through shared pieces of the app. E.g., if you have a GET request which grabs some information from a database, you can spawn a thread to get the info from the different tables and amalgamate it. If you subsequently get a DELETE you can delete all the required information. One key thing here will be to think about transactions if you have more complex SQL statements. (Single queries are implicitly wrapped in transactions anyway, by sqlite, iirc...) There is nothing specific to Android here though, kris -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: I read using threads causes overhead, performance and scalability issues. It is efficient if there are a limited number of clients. So I think using java.nio would be the best option. Any example that shows handling the HTTP methods without blocking. how many concurrent requests do you expect? 10, 100, 1000, more? if ten or so its no problem, if more you probably should change the platform pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, Seems like org.apache.http.nio.protocol.HttpAsyncService does not exist in Android. Can anybody suggest me how to make my HTTP Server asynchronous? Any help is appreciated. Thanks in advance! On Friday, December 14, 2012 8:56:05 AM UTC+2, Archana wrote: Hi Kris, Can I use HttpAsyncRequestHandler and HttpAsyncService for my Android app? Can I use the same socket/port in this case? Thanks! On Thursday, December 13, 2012 12:22:57 PM UTC+2, skink wrote: Archana wrote: Hi, when I issue GET, POST requests simultaneously, timeout occurs in Mozilla Poster (as I mentioned below). I need to handle asynchronous requests (non-blocking) as I m using the same socket/port. so follow Kris's advice, he already answered what to do pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, Seems like org.apache.http.nio.protocol.HttpAsyncService does not exist in Android. Can anybody suggest me how to make my HTTP Server asynchronous? Any help is appreciated. Thanks in advance! quoting Kris: But if you insist that your app is special, the common pattern is to have a dedicated thread that handles the connection and forks off worker threads to handle incoming requests, this is the common case. pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, Is it like having separate thread for each request(GET/POST/DELETE) ? Can you please explain? I was also thinking of AsyncTask, message queue or multithreading. Thanks! On Monday, December 17, 2012 1:28:25 PM UTC+2, skink wrote: Archana wrote: Hi, Seems like org.apache.http.nio.protocol.HttpAsyncService does not exist in Android. Can anybody suggest me how to make my HTTP Server asynchronous? Any help is appreciated. Thanks in advance! quoting Kris: But if you insist that your app is special, the common pattern is to have a dedicated thread that handles the connection and forks off worker threads to handle incoming requests, this is the common case. pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, Is it like having separate thread for each request(GET/POST/DELETE) ? yes pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
On Mon, Dec 17, 2012 at 6:35 AM, Archana ramalingam.arch...@gmail.com wrote: Hi, Is it like having separate thread for each request(GET/POST/DELETE) ? Can you please explain? I was also thinking of AsyncTask, message queue or multithreading. Thanks! Basically, those are all equivalent... AsyncTask is using a thread pool under the hood, a message queue will probably be a key step in using multi threading also. One nice thing about these requests is that handling them typically doesn't involve much cross communication between requests: as long as you can serialize on transactions through shared pieces of the app. E.g., if you have a GET request which grabs some information from a database, you can spawn a thread to get the info from the different tables and amalgamate it. If you subsequently get a DELETE you can delete all the required information. One key thing here will be to think about transactions if you have more complex SQL statements. (Single queries are implicitly wrapped in transactions anyway, by sqlite, iirc...) There is nothing specific to Android here though, kris -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
I m getting a Timeout or No Response from server in Mozilla Poster(when I issue GET and DELETE requests), while able to see the response from the server in the logs. So I thought, this is due to blocking of sockets/ports(as I am utilizing only one in my case). On Thursday, December 13, 2012 9:03:53 AM UTC+2, Archana wrote: Hi, Thanks for the input. It is part of research project (so we are using HTTP servers) and we also want to monitor battery in this scenario. As I am relatively new to developing these, please let me know if I am to use the code similar to Page 31, 32 of http://hc.apache.org/httpcomponents-core-ga/tutorial/pdf/httpcore-tutorial.pdf? Thank you! On Wednesday, December 12, 2012 5:20:46 PM UTC+2, Kristopher Micinski wrote: This is nothing Android specific. Designing HTTP servers that follow this pattern is a common Java problem, but in my mind there is no reason that you should be doing this on Android. Instead you should be communicating with your service using messages to and from a service using a smart mechanism (GCM) to talk back to your apps. HTTP servers will kill the battery... But if you insist that your app is special, the common pattern is to have a dedicated thread that handles the connection and forks off worker threads to handle incoming requests, this is the common case. Is there any reason you'd want truly non blocking I/O? But the answer is Java nio, which Android *does* include: http://developer.android.com/reference/java/nio/package-summary.html http://blog.codepainters.com/2012/02/17/why-java-nio-is-a-better-idea-for-android/ Kris On Wed, Dec 12, 2012 at 8:27 AM, Archana ramalinga...@gmail.com wrote: Hi, I used request.getRequestLine().getMethod(); that tells me if the method is GET/DELETE/POST and handle it accordingly. Any idea of how can I make my HTTP server in the Android phone non-blocking? I mean to simultaneously handle POST, GET and DELETE requests ? Thank you! On Tuesday, December 4, 2012 12:58:42 PM UTC+2, skink wrote: Archana wrote: Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. i have not used HttpService so cant help much pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-d...@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: I m getting a Timeout or No Response from server in Mozilla Poster(when I issue GET and DELETE requests), while able to see the response from the server in the logs. So I thought, this is due to blocking of sockets/ports(as I am utilizing only one in my case). and your server's code is? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
I m including the server code for GET request. Post and delete follow the same pattern: while(true){ socket = serverSocket.accept(); conn = new DefaultHttpServerConnection(); conn.bind(socket,new BasicHttpParams()); HttpRequest request; try { request = conn.receiveRequestHeader(); String target = request.getRequestLine().getUri(); target = target.replaceAll(/,); String method = request.getRequestLine().getMethod(); Code for handling GET request: -- if(method.equals(GET)) { if(checkFileExisting()) { BufferedReader reader = new BufferedReader(new FileReader(new File(getFilesDir()+File.separator+script.json))); String read; StringBuilder builder = new StringBuilder(); while((read = reader.readLine()) != null) { builder.append(read); } String JSONContents = builder.toString(); reader.close(); JSONObject jsonObject; try { jsonObject = new JSONObject(JSONContents); String name = jsonObject.getString(name); JSONObject stateObject = jsonObject.getJSONObject(state); String stateValue = stateObject.getString(value); if(name.equals(target)) { HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, OK); response.setEntity(new StringEntity(State is: + stateValue)); conn.sendResponseHeader(response); conn.sendResponseEntity(response); } else { HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 404, Not Found); response.setEntity(new StringEntity(The requested resource + target + could not be found due to mismatch!!)); conn.sendResponseHeader(response); conn.sendResponseEntity(response); } } catch (JSONException e) { e.printStackTrace(); } } else { HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 404, Not Found); response.setEntity(new StringEntity(The requested resource + target + could not be found!!)); conn.sendResponseHeader(response); conn.sendResponseEntity(response); }} Thanks! On Thursday, December 13, 2012 10:10:13 AM UTC+2, skink wrote: Archana wrote: I m getting a Timeout or No Response from server in Mozilla Poster(when I issue GET and DELETE requests), while able to see the response from the server in the logs. So I thought, this is due to blocking of sockets/ports(as I am utilizing only one in my case). and your server's code is? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: I m including the server code for GET request. Post and delete follow the same pattern: did you try to debug it and see where it hangs? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, when I issue GET, POST requests simultaneously, timeout occurs in Mozilla Poster (as I mentioned below). I need to handle asynchronous requests (non-blocking) as I m using the same socket/port. On Thursday, December 13, 2012 11:20:09 AM UTC+2, skink wrote: Archana wrote: I m including the server code for GET request. Post and delete follow the same pattern: did you try to debug it and see where it hangs? pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, when I issue GET, POST requests simultaneously, timeout occurs in Mozilla Poster (as I mentioned below). I need to handle asynchronous requests (non-blocking) as I m using the same socket/port. so follow Kris's advice, he already answered what to do pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi Kris, Can I use HttpAsyncRequestHandler and HttpAsyncService for my Android app? Can I use the same socket/port in this case? Thanks! On Thursday, December 13, 2012 12:22:57 PM UTC+2, skink wrote: Archana wrote: Hi, when I issue GET, POST requests simultaneously, timeout occurs in Mozilla Poster (as I mentioned below). I need to handle asynchronous requests (non-blocking) as I m using the same socket/port. so follow Kris's advice, he already answered what to do pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
Hi, I used request.getRequestLine().getMethod(); that tells me if the method is GET/DELETE/POST and handle it accordingly. Any idea of how can I make my HTTP server in the Android phone non-blocking? I mean to simultaneously handle POST, GET and DELETE requests ? Thank you! On Tuesday, December 4, 2012 12:58:42 PM UTC+2, skink wrote: Archana wrote: Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. i have not used HttpService so cant help much pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
This is nothing Android specific. Designing HTTP servers that follow this pattern is a common Java problem, but in my mind there is no reason that you should be doing this on Android. Instead you should be communicating with your service using messages to and from a service using a smart mechanism (GCM) to talk back to your apps. HTTP servers will kill the battery... But if you insist that your app is special, the common pattern is to have a dedicated thread that handles the connection and forks off worker threads to handle incoming requests, this is the common case. Is there any reason you'd want truly non blocking I/O? But the answer is Java nio, which Android *does* include: http://developer.android.com/reference/java/nio/package-summary.html http://blog.codepainters.com/2012/02/17/why-java-nio-is-a-better-idea-for-android/ Kris On Wed, Dec 12, 2012 at 8:27 AM, Archana ramalingam.arch...@gmail.com wrote: Hi, I used request.getRequestLine().getMethod(); that tells me if the method is GET/DELETE/POST and handle it accordingly. Any idea of how can I make my HTTP server in the Android phone non-blocking? I mean to simultaneously handle POST, GET and DELETE requests ? Thank you! On Tuesday, December 4, 2012 12:58:42 PM UTC+2, skink wrote: Archana wrote: Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. i have not used HttpService so cant help much pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: Identifying HTTP Get requests in Android
Hi, Thanks for the input. It is part of research project (so we are using HTTP servers) and we also want to monitor battery in this scenario. As I am relatively new to developing these, please let me know if I am to use the code similar to Page 31, 32 of http://hc.apache.org/httpcomponents-core-ga/tutorial/pdf/httpcore-tutorial.pdf ? Thank you! On Wednesday, December 12, 2012 5:20:46 PM UTC+2, Kristopher Micinski wrote: This is nothing Android specific. Designing HTTP servers that follow this pattern is a common Java problem, but in my mind there is no reason that you should be doing this on Android. Instead you should be communicating with your service using messages to and from a service using a smart mechanism (GCM) to talk back to your apps. HTTP servers will kill the battery... But if you insist that your app is special, the common pattern is to have a dedicated thread that handles the connection and forks off worker threads to handle incoming requests, this is the common case. Is there any reason you'd want truly non blocking I/O? But the answer is Java nio, which Android *does* include: http://developer.android.com/reference/java/nio/package-summary.html http://blog.codepainters.com/2012/02/17/why-java-nio-is-a-better-idea-for-android/ Kris On Wed, Dec 12, 2012 at 8:27 AM, Archana ramalinga...@gmail.comjavascript: wrote: Hi, I used request.getRequestLine().getMethod(); that tells me if the method is GET/DELETE/POST and handle it accordingly. Any idea of how can I make my HTTP server in the Android phone non-blocking? I mean to simultaneously handle POST, GET and DELETE requests ? Thank you! On Tuesday, December 4, 2012 12:58:42 PM UTC+2, skink wrote: Archana wrote: Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. i have not used HttpService so cant help much pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-d...@googlegroups.comjavascript: To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. On Monday, December 3, 2012 3:26:48 PM UTC+2, skink wrote: Archana wrote: My question is when I use Poster, how will the server(in the phone) know that it has received Http Get or Delete requests? Thanks see HttpRequest docs pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi, is it using HttpService.handleRequest? Please help as I dont have much idea of using HTTP Core. i have not used HttpService so cant help much pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: Hi all, I ve implemented HTTP in Android using 2 devices. They communicate with each other when one acts as server and other as client. But my question is if I issue a HTTP Get request from Poster, example, http://IP address:port number to server in one phone, how will I know that it has received the request? And where do I have to define the response? Please help me as am new to Web server functionality. Thanks! http://groups.google.com/group/android-developers/browse_thread/thread/e7224f9beb036207/f01ec164487f69a5#f01ec164487f69a5 pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
My question is when I use Poster, how will the server(in the phone) know that it has received Http Get or Delete requests? Thanks On Monday, December 3, 2012 3:11:02 PM UTC+2, skink wrote: Archana wrote: Hi all, I ve implemented HTTP in Android using 2 devices. They communicate with each other when one acts as server and other as client. But my question is if I issue a HTTP Get request from Poster, example, http://IP address:port number to server in one phone, how will I know that it has received the request? And where do I have to define the response? Please help me as am new to Web server functionality. Thanks! http://groups.google.com/group/android-developers/browse_thread/thread/e7224f9beb036207/f01ec164487f69a5#f01ec164487f69a5 pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Identifying HTTP Get requests in Android
Archana wrote: My question is when I use Poster, how will the server(in the phone) know that it has received Http Get or Delete requests? Thanks see HttpRequest docs pskink -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en