java.net

Class DatagramSocketImpl

  • All Implemented Interfaces:
    SocketOptions

    public abstract class DatagramSocketImpl
    extends Object
    implements SocketOptions
    Abstract datagram and multicast socket implementation base class.
    Since:
    JDK1.1
    • Field Detail

      • localPort

        protected int localPort
        The local port number.
    • Constructor Detail

      • DatagramSocketImpl

        public DatagramSocketImpl()
    • Method Detail

      • create

        protected abstract void create()
                                throws SocketException
        Creates a datagram socket.
        Throws:
        SocketException - if there is an error in the underlying protocol, such as a TCP error.
      • bind

        protected abstract void bind(int lport,
                InetAddress laddr)
                              throws SocketException
        Binds a datagram socket to a local port and address.
        Parameters:
        lport - the local port
        laddr - the local address
        Throws:
        SocketException - if there is an error in the underlying protocol, such as a TCP error.
      • send

        protected abstract void send(DatagramPacket p)
                              throws IOException
        Sends a datagram packet. The packet contains the data and the destination address to send the packet to.
        Parameters:
        p - the packet to be sent.
        Throws:
        IOException - if an I/O exception occurs while sending the datagram packet.
        PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
      • connect

        protected void connect(InetAddress address,
                   int port)
                        throws SocketException
        Connects a datagram socket to a remote destination. This associates the remote address with the local socket so that datagrams may only be sent to this destination and received from this destination. This may be overridden to call a native system connect.

        If the remote destination to which the socket is connected does not exist, or is otherwise unreachable, and if an ICMP destination unreachable packet has been received for that address, then a subsequent call to send or receive may throw a PortUnreachableException. Note, there is no guarantee that the exception will be thrown.

        Parameters:
        address - the remote InetAddress to connect to
        port - the remote port number
        Throws:
        SocketException - may be thrown if the socket cannot be connected to the remote destination
        Since:
        1.4
      • disconnect

        protected void disconnect()
        Disconnects a datagram socket from its remote destination.
        Since:
        1.4
      • peek

        protected abstract int peek(InetAddress i)
                             throws IOException
        Peek at the packet to see who it is from. Updates the specified InetAddress to the address which the packet came from.
        Parameters:
        i - an InetAddress object
        Returns:
        the port number which the packet came from.
        Throws:
        IOException - if an I/O exception occurs
        PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
      • peekData

        protected abstract int peekData(DatagramPacket p)
                                 throws IOException
        Peek at the packet to see who it is from. The data is copied into the specified DatagramPacket. The data is returned, but not consumed, so that a subsequent peekData/receive operation will see the same data.
        Parameters:
        p - the Packet Received.
        Returns:
        the port number which the packet came from.
        Throws:
        IOException - if an I/O exception occurs
        PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
        Since:
        1.4
      • receive

        protected abstract void receive(DatagramPacket p)
                                 throws IOException
        Receive the datagram packet.
        Parameters:
        p - the Packet Received.
        Throws:
        IOException - if an I/O exception occurs while receiving the datagram packet.
        PortUnreachableException - may be thrown if the socket is connected to a currently unreachable destination. Note, there is no guarantee that the exception will be thrown.
      • setTTL

        @Deprecated
        protected abstract void setTTL(byte ttl)
                                throws IOException
        Deprecated. use setTimeToLive instead.
        Set the TTL (time-to-live) option.
        Parameters:
        ttl - a byte specifying the TTL value
        Throws:
        IOException - if an I/O exception occurs while setting the time-to-live option.
        See Also:
        getTTL()
      • getTTL

        @Deprecated
        protected abstract byte getTTL()
                                throws IOException
        Deprecated. use getTimeToLive instead.
        Retrieve the TTL (time-to-live) option.
        Returns:
        a byte representing the TTL value
        Throws:
        IOException - if an I/O exception occurs while retrieving the time-to-live option
        See Also:
        setTTL(byte)
      • setTimeToLive

        protected abstract void setTimeToLive(int ttl)
                                       throws IOException
        Set the TTL (time-to-live) option.
        Parameters:
        ttl - an int specifying the time-to-live value
        Throws:
        IOException - if an I/O exception occurs while setting the time-to-live option.
        See Also:
        getTimeToLive()
      • getTimeToLive

        protected abstract int getTimeToLive()
                                      throws IOException
        Retrieve the TTL (time-to-live) option.
        Returns:
        an int representing the time-to-live value
        Throws:
        IOException - if an I/O exception occurs while retrieving the time-to-live option
        See Also:
        setTimeToLive(int)
      • join

        protected abstract void join(InetAddress inetaddr)
                              throws IOException
        Join the multicast group.
        Parameters:
        inetaddr - multicast address to join.
        Throws:
        IOException - if an I/O exception occurs while joining the multicast group.
      • leave

        protected abstract void leave(InetAddress inetaddr)
                               throws IOException
        Leave the multicast group.
        Parameters:
        inetaddr - multicast address to leave.
        Throws:
        IOException - if an I/O exception occurs while leaving the multicast group.
      • joinGroup

        protected abstract void joinGroup(SocketAddress mcastaddr,
                     NetworkInterface netIf)
                                   throws IOException
        Join the multicast group.
        Parameters:
        mcastaddr - address to join.
        netIf - specifies the local interface to receive multicast datagram packets
        Throws:
        IOException - if an I/O exception occurs while joining the multicast group
        Since:
        1.4
      • leaveGroup

        protected abstract void leaveGroup(SocketAddress mcastaddr,
                      NetworkInterface netIf)
                                    throws IOException
        Leave the multicast group.
        Parameters:
        mcastaddr - address to leave.
        netIf - specified the local interface to leave the group at
        Throws:
        IOException - if an I/O exception occurs while leaving the multicast group
        Since:
        1.4
      • close

        protected abstract void close()
        Close the socket.
      • getLocalPort

        protected int getLocalPort()
        Gets the local port.
        Returns:
        an int representing the local port value
      • getFileDescriptor

        protected FileDescriptor getFileDescriptor()
        Gets the datagram socket file descriptor.
        Returns:
        a FileDescriptor object representing the datagram socket file descriptor

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/net/DatagramSocketImpl.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut