sockets - Receive UDP Broadcast fails when change wifi Status Android -
i have receive routine inside asyntask:
byte[] message = new byte[1500]; s = new datagramsocket(null); s.setreuseaddress(true); s.bind(new inetsocketaddress(dataclass.getdataclass().gggport)); p = new datagrampacket(message, message.length); s.setsotimeout(500); s.setbroadcast(true); dataclass.getdataclass().setgoout(true); s.receive(p); this code works perfect receive udp broadcast packets in android, have 1 problem: when in android receiving udp packets , turn off access point (no more packets arrives) , after turn on access point, have same problem : timeout.
in situation, if disable wifi , enable wifi works time...
anyone same problem?
you need re-create , re-bind receiving socket each time device's connection status changes.
Comments
Post a Comment