Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy can't my application receive the data using UDP in Hotsport network?
    primarykey
    data
    text
    <p>Why can't my application receive the data using UDP in Hotsport network? But my application can receive the data using UDP in normal Wi-Fi network. The code of the sender is:</p> <pre><code>@Override public void run() { super.run(); DatagramPacket dataPacket = null; try { udpSocket = new DatagramSocket(DEFAULT_PORT); dataPacket = new DatagramPacket(buffer, MAX_DATA_PACKET_LENGTH); while (isRunning) { String address = getLocalIPAddress(); if (address != null) { byte[] data = address.getBytes(); dataPacket.setData(data); dataPacket.setLength(data.length); dataPacket.setPort(DEFAULT_PORT); InetAddress broadcastAddr; broadcastAddr = InetAddress.getByName("255.255.255.255"); dataPacket.setAddress(broadcastAddr); try { Log.i(DazzleApplication.TAG,"Sending----&gt;"+address); sleep(3000); } catch (Exception e) { e.printStackTrace(); } } } if (udpSocket != null) udpSocket.close(); } catch (Exception e) { e.printStackTrace(); } } </code></pre> <p>The code of the receiver is:</p> <pre><code>public void run() { DatagramPacket udpPacket=null; byte[] data=null ; try { udpSocket = new DatagramSocket(43708); udpSocket.setSoTimeout(3000); data= new byte[256]; udpPacket= new DatagramPacket(data, 256); } catch (SocketException e) { e.printStackTrace(); System.out.println(e.toString()); } while (start) { System.out.println("DazzleTest Receive....."); try { udpSocket.receive(udpPacket); } catch (Exception e) { e.printStackTrace(); System.out.println(e.toString()); } if (udpPacket.getLength() != 0) { String codeString = new String(data, 0, udpPacket.getLength()); Message msg = new Message(); msg.obj = codeString; mH.sendMessageDelayed(msg, 1000); System.out.println("receiver---&gt;"+codeString); }else{ System.out.println("receiver null"); } } if (udpSocket != null) { udpSocket.close(); } } </code></pre> <p>Why? Who can explain this case? The UDP can't work in Hotspot??</p> <p>Update the following information: The sender of the socket run in the HTC HD which is opened Hotspot. it can catch the exception: <code>java.net.SocketException: Network is unreachable: connect</code> .</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload