Code example for DatagramPacket

Methods: getAddress, getData, getLength, getOffset, getPort

0
        return pack.getPort();
    } 
 
    @Override 
    public void send(DatagramPacket packet) throws IOException {
        int port = isNativeConnected ? 0 : packet.getPort();
        InetAddress address = isNativeConnected ? null : packet.getAddress();
        netImpl.send(fd, packet.getData(), packet.getOffset(), packet.getLength(), port, address);
    } 
 
    public void setOption(int optID, Object val) throws SocketException {
        netImpl.setSocketOption(fd, optID, val);
    } 
 
    @Override 
    public void setTimeToLive(int ttl) throws IOException {
        setOption(IP_MULTICAST_TTL, Integer.valueOf(ttl));
    } 
 
    @Override 
    public void setTTL(byte ttl) throws IOException {