congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
UDPNIOConnection
Code IndexAdd Tabnine to your IDE (free)

How to use
UDPNIOConnection
in
org.glassfish.grizzly.nio.transport

Best Java code snippets using org.glassfish.grizzly.nio.transport.UDPNIOConnection (Showing top 20 results out of 315)

origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Drops non-source specific membership in a multicast group.
 * If this connection doesn't have non-source specific membership in the group
 * on the given interface to receive datagrams then this method call
 * has no effect. Otherwise this connection drops the group membership.
 * 
 * @param group The multicast address to join
 * @param networkInterface The network interface on which to join the group
 * 
 * @throws IOException 
 */
public void drop(final InetAddress group,
    final NetworkInterface networkInterface) throws IOException {
  drop(group, networkInterface, null);
}

origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * Joins a multicast group to begin receiving all datagrams sent to the
 * group. If this connection is currently a member of the group on the given
 * interface to receive all datagrams then this method call has no effect.
 * Otherwise this connection joins the requested group and channel's
 * membership in not source-specific.
 *
 * A multicast connection may join several multicast groups, including the
 * same group on more than one interface. An implementation may impose a
 * limit on the number of groups that may be joined at the same time.
 *
 * @param group The multicast address to join
 * @param networkInterface The network interface on which to join the group
 *
 * @throws IOException
 */
public void join(final InetAddress group,
    final NetworkInterface networkInterface) throws IOException {
  join(group, networkInterface, null);
}
origin: javaee/grizzly

/**
 * Method will be called, when some data was read on the connection
 */
protected final void onRead(Buffer data, int size) {
  if (size > 0) {
    notifyProbesRead(this, data, size);
  }
  checkEmptyRead(size);
}
origin: javaee/grizzly

final Object key = it.next();
if (networkInterface.equals(networkInterface0(key))
    && sourceAddress0(key) == null) {
  block0(key, source);
origin: javaee/grizzly

@Override
public void onComplete(final Context context, final Object data)
    throws IOException {
  final UDPNIOConnection connection =
      (UDPNIOConnection) context.getConnection();
  if (completionHandler != null) {
    completionHandler.completed(connection);
  }
  if (!connection.isStandalone()) {
    connection.enableInitialOpRead();
  }
}
origin: javaee/grizzly

final Object key = it.next();
if (networkInterface.equals(networkInterface0(key))) {
  drop0(key);
  it.remove();
origin: javaee/grizzly

protected void addRecord(Connection connection,
    Buffer buffer,
    CompletionHandler completionHandler,
    Interceptor<ReadResult> interceptor) {
  
  final AsyncReadQueueRecord record = AsyncReadQueueRecord.create(
      connection, buffer,
      completionHandler, interceptor);
  ((UDPNIOConnection) connection).getAsyncReadQueue().offer(record);
}
origin: javaee/grizzly

UDPNIOConnection obtainNIOConnection(DatagramChannel channel) {
  UDPNIOConnection connection = new UDPNIOConnection(this, channel);
  configureNIOConnection(connection);
  return connection;
}
origin: javaee/grizzly

private static void abortConnection(final UDPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler,
    final Throwable failure) {
  connection.closeSilently();
  if (completionHandler != null) {
    completionHandler.failed(failure);
  }
}
origin: javaee/grizzly

private int readConnected(final UDPNIOConnection connection, Buffer buffer,
    final ReadResult<Buffer, SocketAddress> currentResult) throws IOException {
  final int read;
  final int oldPos = buffer.position();
  if (buffer.isComposite()) {
    final ByteBufferArray array = buffer.toByteBufferArray();
    final ByteBuffer[] byteBuffers = array.getArray();
    final int size = array.size();
    read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size);
    array.restore();
    array.recycle();
  } else {
    read = ((DatagramChannel) connection.getChannel()).read(
        buffer.toByteBuffer());
  }
  final boolean hasRead = (read > 0);
  if (hasRead) {
    buffer.position(oldPos + read);
  }
  
  if (hasRead && currentResult != null) {
    currentResult.setMessage(buffer);
    currentResult.setReadSize(currentResult.getReadSize() + read);
    currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder);
  }
  return read;
}
origin: javaee/grizzly

  @Override
  public void run(final UDPNIOConnection connection) throws Exception {
    // Join the multicast group
    connection.join(groupAddr, ni, source);
    
    // construct destination multicast address to send the message to
    final InetSocketAddress peerAddr =
        new InetSocketAddress(groupAddr,
        ((InetSocketAddress) connection.getLocalAddress()).getPort());
    
    // Create Future to be able to block until the message is sent
    final FutureImpl<WriteResult<String, SocketAddress>> writeFuture =
        Futures.createSafeFuture();
    
    // Send the greeting message to group
    connection.write(peerAddr, "joined the group " + groupAddr,
        Futures.toCompletionHandler(writeFuture));
    
    // Block until the message is sent
    writeFuture.get(10, TimeUnit.SECONDS);
  }
}
origin: org.glassfish.grizzly/grizzly-core

final Object key = it.next();
if (networkInterface.equals(networkInterface0(key))
    && sourceAddress0(key) == null) {
  block0(key, source);
origin: javaee/grizzly

@Override
public void onComplete(final Context context, final Object data)
    throws IOException {
  final UDPNIOConnection connection =
      (UDPNIOConnection) context.getConnection();
  if (completionHandler != null) {
    completionHandler.completed(connection);
  }
  if (!connection.isStandalone()) {
    connection.enableInitialOpRead();
  }
}
origin: javaee/grizzly

final Object key = it.next();
if (networkInterface.equals(networkInterface0(key))) {
  drop0(key);
  it.remove();
origin: org.glassfish.grizzly/grizzly-websockets-server

protected void addRecord(Connection connection,
    Buffer buffer,
    CompletionHandler completionHandler,
    Interceptor<ReadResult> interceptor) {
  
  final AsyncReadQueueRecord record = AsyncReadQueueRecord.create(
      connection, buffer,
      completionHandler, interceptor);
  ((UDPNIOConnection) connection).getAsyncReadQueue().offer(record);
}
origin: javaee/grizzly

UDPNIOConnection obtainNIOConnection(DatagramChannel channel) {
  UDPNIOConnection connection = new UDPNIOConnection(this, channel);
  configureNIOConnection(connection);
  return connection;
}
origin: org.glassfish.grizzly/grizzly-websockets-server

private static void abortConnection(final UDPNIOConnection connection,
    final CompletionHandler<Connection> completionHandler,
    final Throwable failure) {
  connection.closeSilently();
  if (completionHandler != null) {
    completionHandler.failed(failure);
  }
}
origin: javaee/grizzly

private int readConnected(final UDPNIOConnection connection, Buffer buffer,
    final ReadResult<Buffer, SocketAddress> currentResult) throws IOException {
  final int read;
  final int oldPos = buffer.position();
  if (buffer.isComposite()) {
    final ByteBufferArray array = buffer.toByteBufferArray();
    final ByteBuffer[] byteBuffers = array.getArray();
    final int size = array.size();
    read = (int) ((DatagramChannel) connection.getChannel()).read(byteBuffers, 0, size);
    array.restore();
    array.recycle();
  } else {
    read = ((DatagramChannel) connection.getChannel()).read(
        buffer.toByteBuffer());
  }
  final boolean hasRead = (read > 0);
  if (hasRead) {
    buffer.position(oldPos + read);
  }
  
  if (hasRead && currentResult != null) {
    currentResult.setMessage(buffer);
    currentResult.setReadSize(currentResult.getReadSize() + read);
    currentResult.setSrcAddressHolder(connection.peerSocketAddressHolder);
  }
  return read;
}
origin: org.glassfish.grizzly/grizzly-websockets-server

final Object key = it.next();
if (networkInterface.equals(networkInterface0(key))
    && sourceAddress0(key) == null) {
  block0(key, source);
origin: javaee/grizzly

/**
 * Method will be called, when some data was read on the connection
 */
protected final void onRead(Buffer data, int size) {
  if (size > 0) {
    notifyProbesRead(this, data, size);
  }
  checkEmptyRead(size);
}
org.glassfish.grizzly.nio.transportUDPNIOConnection

Javadoc

org.glassfish.grizzly.Connection implementation for the UDPNIOTransport

Most used methods

  • drop
    Drops membership in a multicast group. If the source parameter is null - this method call is equival
  • join
    Joins a multicast group to begin receiving datagrams sent to the group from a given source address.
  • <init>
  • block0
  • checkEmptyRead
  • closeSilently
  • drop0
  • enableInitialOpRead
  • getAsyncReadQueue
  • getChannel
  • getReadBufferSize
  • getWriteBufferSize
  • getReadBufferSize,
  • getWriteBufferSize,
  • invoke,
  • isConnected,
  • isStandalone,
  • join0,
  • networkInterface0,
  • notifyProbesConnect,
  • notifyProbesRead,
  • notifyProbesWrite

Popular in Java

  • Finding current android device location
  • getResourceAsStream (ClassLoader)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • scheduleAtFixedRate (Timer)
  • String (java.lang)
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JOptionPane (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now