wifi chat on android

▼魔方 西西 提交于 2020-01-11 07:50:36

问题


Is Wifi chat is possible on android?

My requirement is my Pc thats connected with a wifi dongle and my android device has wifi. I want to convert my pc to server and android device to client and implement the chat.

Is this possible?

Please help me out.


回答1:


Obviously it's possible. To start with, you could make a peer-to-peer chat over UDP, hard-coding each other's IP numbers into the other's programs. A few lines of python on the PC, a few lines of Java on the Android. Then you could start adding the functionality you need to make it client-server: add a broadcast listener on the PC, so that it can auto-detect clients, then you can eliminate the schlock hard-coded IP numbers. And build up from there.


Example server-side in Python:
jcomeau@intrepid:/usr/src/xmlvm.svn$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> chatter = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
>>> chatter.bind(('192.168.1.121', 9999))
>>> chatter.sendto('this is a test', ('192.168.1.144', 6666))
14


来源:https://stackoverflow.com/questions/5711535/wifi-chat-on-android

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!