Example #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override protected void create(boolean stream) throws java.io.IOException
        protected internal override void Create(bool stream)
        {
            if (!stream)
            {
                throw new UnsupportedOperationException("Must be a stream socket");
            }
            Fd = SdpSupport.createSocket();
            if (Socket_Renamed != null)
            {
                Socket_Renamed.SetCreated();
            }
            if (ServerSocket_Renamed != null)
            {
                ServerSocket_Renamed.SetCreated();
            }
        }
Example #2
0
        /// <summary>
        /// The workhorse of the connection operation.  Tries several times to
        /// establish a connection to the given <host, port>.  If unsuccessful,
        /// throws an IOException indicating what went wrong.
        /// </summary>

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: synchronized void doConnect(InetAddress address, int port, int timeout) throws java.io.IOException
        internal virtual void DoConnect(InetAddress address, int port, int timeout)
        {
            lock (this)
            {
                lock (FdLock)
                {
                    if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound))
                    {
                        NetHooks.beforeTcpConnect(Fd, address, port);
                    }
                }
                try
                {
                    AcquireFD();
                    try
                    {
                        SocketConnect(address, port, timeout);
                        /* socket may have been closed during poll/select */
                        lock (FdLock)
                        {
                            if (ClosePending)
                            {
                                throw new SocketException("Socket closed");
                            }
                        }
                        // If we have a ref. to the Socket, then sets the flags
                        // created, bound & connected to true.
                        // This is normally done in Socket.connect() but some
                        // subclasses of Socket may call impl.connect() directly!
                        if (Socket_Renamed != null)
                        {
                            Socket_Renamed.SetBound();
                            Socket_Renamed.SetConnected();
                        }
                    }
                    finally
                    {
                        ReleaseFD();
                    }
                }
                catch (IOException e)
                {
                    Close();
                    throw e;
                }
            }
        }
Example #3
0
        /// <summary>
        /// Binds the socket to the specified address of the specified local port. </summary>
        /// <param name="address"> the address </param>
        /// <param name="lport"> the port </param>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected synchronized void bind(InetAddress address, int lport) throws java.io.IOException
        protected internal override void Bind(InetAddress address, int lport)
        {
            lock (this)
            {
                lock (FdLock)
                {
                    if (!ClosePending && (Socket_Renamed == null || !Socket_Renamed.Bound))
                    {
                        NetHooks.beforeTcpBind(Fd, address, lport);
                    }
                }
                SocketBind(address, lport);
                if (Socket_Renamed != null)
                {
                    Socket_Renamed.SetBound();
                }
                if (ServerSocket_Renamed != null)
                {
                    ServerSocket_Renamed.SetBound();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Creates a socket with a boolean that specifies whether this
        /// is a stream socket (true) or an unconnected UDP socket (false).
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: protected synchronized void create(boolean stream) throws java.io.IOException
        protected internal override void Create(bool stream)
        {
            lock (this)
            {
                this.Stream = stream;
                if (!stream)
                {
                    ResourceManager.beforeUdpCreate();
                    // only create the fd after we know we will be able to create the socket
                    Fd = new FileDescriptor();
                    try
                    {
                        SocketCreate(false);
                    }
                    catch (IOException ioe)
                    {
                        ResourceManager.afterUdpClose();
                        Fd = null;
                        throw ioe;
                    }
                }
                else
                {
                    Fd = new FileDescriptor();
                    SocketCreate(true);
                }
                if (Socket_Renamed != null)
                {
                    Socket_Renamed.SetCreated();
                }
                if (ServerSocket_Renamed != null)
                {
                    ServerSocket_Renamed.SetCreated();
                }
            }
        }