sockets - How to programmatically broadcast a String message from PC to multiple USB-attached Android phones? -



sockets - How to programmatically broadcast a String message from PC to multiple USB-attached Android phones? -

my goal: want programmatically broadcast string message (containing scheme time of pc) pc 2 usb-attached android phones.

my attempt:

(1) have 2 android phones attached computer via usb.

(2) utilize "adb -s forward" commands set forwarding of computer port 38300 device ports 38300.

(3) programming android phones: basically, create serversocket on port 38300, set timeout, , phone call accept() method.

(4) programming pc: create socket using this.pchost_socket = new socket("localhost", 38300);, , message containing scheme time of pc sent using oos = new objectoutputstream(this.pchost_socket.getoutputstream()); oos.writeobject(msg);.

problem:

only 1 android phone (in case, phone 067125a40acc819e) has received message.

(1) default behaviour of communication via usb/adb? (2) how programmatically broadcast string message pc multiple usb-attached android phones? (it not necessary utilize socket programming.)

you can't multicast ports on host computer via adb; sec adb forward command steals port 38300 first device , assigns second. if want move forwards solution design scheme utilize range of ports, starting @ 38300 (or whatever like). device 1 gets 38300, device 2 gets 38301, device 3 gets 38302, , on. on device side, utilize same port number devices, simplify app design.

adb -s <device1> forwards tcp:38300 tcp:38300 adb -s <device2> forwards tcp:38301 tcp:38300 adb -s <device3> forwards tcp:38302 tcp:38300 adb -s <device4> forwards tcp:38303 tcp:38300

you need pc software connect of open ports on pc , send message.

android sockets adb

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -