Inheritance: global::java.lang.Object, global::java.net.SocketOptions
Example #1
0
        /// <summary>
        /// Accepts connections. </summary>
        /// <param name="s"> the connection </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected void accept(SocketImpl s) throws java.io.IOException
        protected internal override void Accept(SocketImpl s)
        {
            AcquireFD();
            try
            {
                SocketAccept(s);
            }
            finally
            {
                ReleaseFD();
            }
        }
Example #2
0
        /// <summary>
        /// Subclasses of ServerSocket use this method to override accept()
        /// to return their own subclass of socket.  So a FooServerSocket
        /// will typically hand this method an <i>empty</i> FooSocket.  On
        /// return from implAccept the FooSocket will be connected to a client.
        /// </summary>
        /// <param name="s"> the Socket </param>
        /// <exception cref="java.nio.channels.IllegalBlockingModeException">
        ///         if this socket has an associated channel,
        ///         and the channel is in non-blocking mode </exception>
        /// <exception cref="IOException"> if an I/O error occurs when waiting
        /// for a connection.
        /// @since   JDK1.1
        /// @revised 1.4
        /// @spec JSR-51 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected final void implAccept(Socket s) throws java.io.IOException
        protected internal void ImplAccept(Socket s)
        {
            SocketImpl si = null;

            try
            {
                if (s.Impl_Renamed == null)
                {
                    s.SetImpl();
                }
                else
                {
                    s.Impl_Renamed.reset();
                }
                si             = s.Impl_Renamed;
                s.Impl_Renamed = null;
                si.Address     = new InetAddress();
                si.Fd          = new FileDescriptor();
                Impl.Accept(si);

                SecurityManager security = System.SecurityManager;
                if (security != null)
                {
                    security.CheckAccept(si.InetAddress.HostAddress, si.Port);
                }
            }
            catch (IOException e)
            {
                if (si != null)
                {
                    si.Reset();
                }
                s.Impl_Renamed = si;
                throw e;
            }
            catch (SecurityException e)
            {
                if (si != null)
                {
                    si.Reset();
                }
                s.Impl_Renamed = si;
                throw e;
            }
            s.Impl_Renamed = si;
            s.PostAccept();
        }
Example #3
0
 private void SetImpl()
 {
     if (Factory != null)
     {
         Impl_Renamed = Factory.CreateSocketImpl();
         CheckOldImpl();
     }
     else
     {
         // No need to do a checkOldImpl() here, we know it's an up to date
         // SocketImpl!
         Impl_Renamed = new SocksSocketImpl();
     }
     if (Impl_Renamed != null)
     {
         Impl_Renamed.ServerSocket = this;
     }
 }
Example #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void socketAccept(SocketImpl s) throws java.io.IOException
        internal override void SocketAccept(SocketImpl s)
        {
            int nativefd = CheckAndReturnNativeFD();

            if (s == null)
            {
                throw new NullPointerException("socket is null");
            }

            int newfd = -1;

            InetSocketAddress[] isaa = new InetSocketAddress[1];
            if (Timeout_Renamed <= 0)
            {
                newfd = accept0(nativefd, isaa);
            }
            else
            {
                configureBlocking(nativefd, false);
                try
                {
                    waitForNewConnection(nativefd, Timeout_Renamed);
                    newfd = accept0(nativefd, isaa);
                    if (newfd != -1)
                    {
                        configureBlocking(newfd, true);
                    }
                }
                finally
                {
                    configureBlocking(nativefd, true);
                }
            }
            /* Update (SocketImpl)s' fd */
            FdAccess.set(s.Fd, newfd);
            /* Update socketImpls remote port, address and localport */
            InetSocketAddress isa = isaa[0];

            s.Port_Renamed = isa.Port;
            s.Address      = isa.Address;
            s.Localport    = Localport;
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected synchronized void accept(SocketImpl s) throws IOException
        protected internal override void Accept(SocketImpl s)
        {
            lock (this)
            {
                if (s is PlainSocketImpl)
                {
                    // pass in the real impl not the wrapper.
                    SocketImpl @delegate = ((PlainSocketImpl)s).Impl;
                    @delegate.Address = new InetAddress();
                    @delegate.Fd      = new FileDescriptor();
                    Impl.Accept(@delegate);
                    // set fd to delegate's fd to be compatible with older releases
                    s.Fd = @delegate.Fd;
                }
                else
                {
                    Impl.Accept(s);
                }
            }
        }
Example #6
0
 internal extern void socketAccept(SocketImpl s);
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: abstract void socketAccept(SocketImpl s) throws java.io.IOException;
        internal abstract void SocketAccept(SocketImpl s);
Example #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void socketAccept(SocketImpl s) throws IOException
        internal override void SocketAccept(SocketImpl s)
        {
            Impl.SocketAccept(s);
        }
Example #9
0
 /// <summary>
 /// Package-private constructor to create a ServerSocket associated with
 /// the given SocketImpl.
 /// </summary>
 internal ServerSocket(SocketImpl impl)
 {
     this.Impl_Renamed = impl;
     impl.ServerSocket = this;
 }