I want to know how to set an android service that listen to a specific port e.g. http://127.0.0.1:12345
The Listening Ports section of the Network tab gives you information about the services and processes on your system that are waiting to service network requests. These services are listening on either a TCP or a User Datagram Protocol (udp) port.
Navigate to Control Panel, System and Security and Windows Firewall. Select Advanced settings and highlight Inbound Rules in the left pane. Right click Inbound Rules and select New Rule. Add the port you need to open and click Next.
University of Michigan researchers discovered that a number of Android apps in the Google Play Store essentially turn smartphones into servers and, as a result, expose the smartphones with insecure, open ports.
Implement your service and use the ServerSocket
class to listen for incoming connections and to act on them. Don't call ServerSocket.accept()
on your UI thread, though. That'll cause your application to not respond. Instead, create a new thread or depending on your actual scenario, an AsyncTask
might be sufficient.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With