public EndPoint RemoteEndPoint_internal(out int error)
        {
            error = 0;
            java.net.InetSocketAddress remoteAddr = null;

            if (jSocket == null || !jSocket.isBound())
            {
                return(null);
            }

            try
            {
                remoteAddr = (java.net.InetSocketAddress)jSocket.getRemoteSocketAddress();
            }
            catch (Exception e)
            {
                remoteAddr = null;
#if DEBUG
                Console.WriteLine("Caught exception during RemoteEndPoint_internal - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
#endif
            }

            if (remoteAddr == null || remoteAddr.getAddress() == null || remoteAddr.getPort() <= 0)
            {
                error = 10057;                 //WSAENOTCONN (Socket is not connected)
                return(null);
            }

            IPHostEntry lipa = Dns.Resolve(remoteAddr.getHostName());
            IPEndPoint  ret  = new IPEndPoint(lipa.AddressList[0], remoteAddr.getPort());
            return(ret);
        }
        public EndPoint LocalEndPoint_internal(out int error)
        {
            error = 0;
            java.net.InetSocketAddress localAddr = null;

            try
            {
                localAddr = (java.net.InetSocketAddress)jSocket.getLocalSocketAddress();
            }
            catch (Exception e)
            {
                localAddr = null;
#if DEBUG
                Console.WriteLine("Caught exception during LocalEndPoint_internal - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace);
#endif
            }

            if (localAddr == null || localAddr.getAddress() == null || localAddr.getPort() < 0)
            {
                return(null);
            }

            IPHostEntry lipa = Dns.Resolve(localAddr.getHostName());
            IPEndPoint  ret  = new IPEndPoint(lipa.AddressList[0], localAddr.getPort());
            return(ret);
        }