开发者

android service to listen to a specific port

开发者 https://www.devze.com 2023-03-13 03:40 出处:网络
I want to know how to set an android service that listen to a specific port e.g. htt开发者_如何转开发p://127.0.0.1:12345Implement your service and use the ServerSocket class to listen for incoming con

I want to know how to set an android service that listen to a specific port e.g. htt开发者_如何转开发p://127.0.0.1:12345


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消