Esempio n. 1
0
 /**
  * Creates a new socket that is not bound to any local address/port and is not connected to any
  * remote address/port. The stream parameter will be ignored since PlainSocketImpl always is a
  * stream socket. Datagram sockets are handled by PlainDatagramSocketImpl.
  *
  * @param stream <code>true</code> for stream sockets, <code>false</code> for datagram sockets
  */
 protected synchronized void create(boolean stream) throws IOException {
   channel = new SocketChannelImpl(false);
   VMChannel vmchannel = channel.getVMChannel();
   vmchannel.initSocket(stream);
   channel.configureBlocking(true);
   impl.getState().setChannelFD(vmchannel.getState());
 }
Esempio n. 2
0
 /**
  * Accepts a new connection on this socket and returns in in the passed in SocketImpl.
  *
  * @param impl The SocketImpl object to accept this connection.
  */
 protected synchronized void accept(SocketImpl impl) throws IOException {
   if (channel == null) create(true);
   if (!(impl instanceof PlainSocketImpl))
     throw new IOException("incompatible SocketImpl: " + impl.getClass().getName());
   PlainSocketImpl that = (PlainSocketImpl) impl;
   VMChannel c = channel.getVMChannel().accept();
   that.impl.getState().setChannelFD(c.getState());
   that.channel = new SocketChannelImpl(c);
   that.setOption(SO_REUSEADDR, Boolean.TRUE);
   // Reset the inherited timeout.
   that.setOption(SO_TIMEOUT, Integer.valueOf(0));
 }
Esempio n. 3
0
 public void close() throws IOException {
   if (!valid) throw new IOException("invalid file descriptor");
   try {
     VMChannel.close(native_fd);
   } finally {
     valid = false;
     closed = true;
   }
 }