Code example for SocketException

Methods: printStackTrace

0
  DatagramSocket openSocket(final int port) {
    try { 
      return new DatagramSocket(port);
    } catch (final SocketException e) {
      // TODO Auto-generated catch block 
      e.printStackTrace();
    } 
    return null; 
  } 
 
  @Background 
  void sendPacket(final DatagramSocket socket, final int port) {
    try { 
      final InetAddress address = InetAddress.getByName(hostname.getText().toString());
 
      final DatagramPacket packet = new DatagramPacket(data.getBytes(), data.length(), address,
          port);
      socket.send(packet);
      Log.d("AndroidUDP", "Sent: " + packet);
      printOutput("Packet sent, waiting for response");