开发者

Socket-programming in Android

i've written a short TCP-Server and TCP-Client in Java. Everthing worked fine while running the TCP-communication. Today I tried to implement my Server in an android-app and got problems with the serversocket.accept-method. Everytime the line with the m开发者_开发问答ethod call serversocket.accept() is executed the systems breaks down.

Do I've to use threads to solve the problem. Or is there any other solution for this Problem?


The system doesn't "breaks". When you launch the "accept()" method, the program waits for an incoming connection. So if it's the activity thread that start this method, it freezes until it has an incoming connection. But if an activity doesn't respond for over 5 second, the program is broken.

Try using a Thread, it's not hard really...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜