java.nio.channels

Class AsynchronousServerSocketChanne- l

  • All Implemented Interfaces:
    Closeable, AutoCloseable, AsynchronousChannel, Channel, NetworkChannel

    public abstract class AsynchronousServerSocketChannel
    extends Object
    implements AsynchronousChannel, NetworkChannel
    An asynchronous channel for stream-oriented listening sockets.

    An asynchronous server-socket channel is created by invoking the open method of this class. A newly-created asynchronous server-socket channel is open but not yet bound. It can be bound to a local address and configured to listen for connections by invoking the bind method. Once bound, the accept method is used to initiate the accepting of connections to the channel's socket. An attempt to invoke the accept method on an unbound channel will cause a NotYetBoundException to be thrown.

    Channels of this type are safe for use by multiple concurrent threads though at most one accept operation can be outstanding at any time. If a thread initiates an accept operation before a previous accept operation has completed then an AcceptPendingException will be thrown.

    Socket options are configured using the setOption method. Channels of this type support the following options:

    Option Name Description
    SO_RCVBUF The size of the socket receive buffer
    SO_REUSEADDR Re-use address

      

    Additional (implementation specific) options may also be supported.

    Usage Example:

      final AsynchronousServerSocketChannel listener =
          AsynchronousServerSocketChannel.open().bind(new InetSocketAddress(5000));
    
      listener.accept(null, new CompletionHandler<AsynchronousSocketChannel,Void>() {
          public void completed(AsynchronousSocketChannel ch, Void att) {
              // accept the next connection
              listener.accept(null, this);
    
              // handle this connection
              handle(ch);
          }
          public void failed(Throwable exc, Void att) {
              ...
          }
      });
     
    Since:
    1.7

Traduction non disponible

Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.

Document créé le 11/06/2005, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/nio/channels/AsynchronousServerSocketChannel.html

L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.

Références

  1. Consulter le document html Langue du document :fr Manuel PHP : https://docs.oracle.com

Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.

Table des matières Haut