コード例 #1
0
 public NFSv4_callbackServerStub(IPAddress bindAddr, int port)
        {
     info = new OncRpcServerTransportRegistrationInfo [] {
         new OncRpcServerTransportRegistrationInfo(NFSv4_callback.NFS4_CALLBACK, 1),
     };
     transports = new OncRpcServerTransport [] {
         new OncRpcUdpServerTransport(this, bindAddr, port, info, 32768),
         new OncRpcTcpServerTransport(this, bindAddr, port, info, 32768)
     };
 }
コード例 #2
0
 public NFSv3ProtocolServerStub(IPAddress bindAddr, int port)
 {
     info = new OncRpcServerTransportRegistrationInfo[] {
     new OncRpcServerTransportRegistrationInfo(NFSv3Protocol.NFS_PROGRAM, 3),
 };
     transports = new OncRpcServerTransport[] {
     new OncRpcUdpServerTransport(this, bindAddr, port, info, 32768),
     new OncRpcTcpServerTransport(this, bindAddr, port, info, 32768)
 };
 }
コード例 #3
0
		/// <summary>
		/// Create a new instance of a <code>OncRpcUdpServerTransport</code> which
		/// encapsulates UDP/IP-based XDR streams of an ONC/RPC server.
		/// </summary>
		/// <remarks>
		/// Create a new instance of a <code>OncRpcUdpServerTransport</code> which
		/// encapsulates UDP/IP-based XDR streams of an ONC/RPC server. Using a
		/// server transport, ONC/RPC calls are received and the corresponding
		/// replies are sent back.
		/// This constructor is a convenience constructor for those transports
		/// handling only a single ONC/RPC program and version number.
		/// </remarks>
		/// <param name="dispatcher">
		/// Reference to interface of an object capable of
		/// dispatching (handling) ONC/RPC calls.
		/// </param>
		/// <param name="bindAddr">The local Internet Address the server will bind to.</param>
		/// <param name="port">
		/// Number of port where the server will wait for incoming
		/// calls.
		/// </param>
		/// <param name="info">
		/// Array of program and version number tuples of the ONC/RPC
		/// programs and versions handled by this transport.
		/// </param>
		/// <param name="bufferSize">
		/// Size of buffer for receiving and sending UDP/IP
		/// datagrams containing ONC/RPC call and reply messages.
		/// </param>
		/// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public OncRpcUdpServerTransport(OncRpcDispatchable dispatcher
			, IPAddress bindAddr, int port, OncRpcServerTransportRegistrationInfo
			[] info, int bufferSize) : base(dispatcher, port, info)
		{
			//
			// Make sure the buffer is large enough and resize system buffers
			// accordingly, if possible.
			//
			if (bufferSize < 1024)
			{
				bufferSize = 1024;
			}
            socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
            if (bindAddr == null) bindAddr = IPAddress.Any;
            IPEndPoint localEP = new IPEndPoint(bindAddr, port);
            socket.Bind(localEP);
            if (port == 0)
			{
				this.port = ((IPEndPoint)(socket.LocalEndPoint)).Port;

			}
			if (socket.SendBufferSize < bufferSize)
			{
                socket.SendBufferSize = bufferSize;
			}
			if (socket.ReceiveBufferSize < bufferSize)
			{
                socket.ReceiveBufferSize = bufferSize;
			}
			//
			// Create the necessary encoding and decoding streams, so we can
			// communicate at all.
			//
			sendingXdr = new org.acplt.oncrpc.XdrUdpEncodingStream(socket, bufferSize);
			receivingXdr = new org.acplt.oncrpc.XdrUdpDecodingStream(socket, bufferSize);
		}
コード例 #4
0
		/// <summary>
		/// Create a new instance of a <code>OncRpcUdpServerTransport</code> which
		/// encapsulates UDP/IP-based XDR streams of an ONC/RPC server.
		/// </summary>
		/// <remarks>
		/// Create a new instance of a <code>OncRpcUdpServerTransport</code> which
		/// encapsulates UDP/IP-based XDR streams of an ONC/RPC server. Using a
		/// server transport, ONC/RPC calls are received and the corresponding
		/// replies are sent back.
		/// This constructor is a convenience constructor for those transports
		/// handling only a single ONC/RPC program and version number.
		/// </remarks>
		/// <param name="dispatcher">
		/// Reference to interface of an object capable of
		/// dispatching (handling) ONC/RPC calls.
		/// </param>
		/// <param name="port">
		/// Number of port where the server will wait for incoming
		/// calls.
		/// </param>
		/// <param name="info">
		/// Array of program and version number tuples of the ONC/RPC
		/// programs and versions handled by this transport.
		/// </param>
		/// <param name="bufferSize">
		/// Size of buffer for receiving and sending UDP/IP
		/// datagrams containing ONC/RPC call and reply messages.
		/// </param>
		/// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public OncRpcUdpServerTransport(org.acplt.oncrpc.server.OncRpcDispatchable dispatcher
			, int port, OncRpcServerTransportRegistrationInfo[] info
			, int bufferSize) : this(dispatcher, null, port, info, bufferSize)
		{
		}
コード例 #5
0
ファイル: jportmap.cs プロジェクト: zjianliu/NFSClient
        /// <summary>
        /// Create a new portmap instance, create the transport registration
        /// information and UDP and TCP-based transports, which will be bound
        /// later to port 111.
        /// </summary>
        /// <remarks>
        /// Create a new portmap instance, create the transport registration
        /// information and UDP and TCP-based transports, which will be bound
        /// later to port 111. The constructor does not start the dispatcher loop.
        /// </remarks>
        /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public jportmap()
        {
            //
            // We only need to register one {progam, version}.
            //
            info = new org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo[] { new
                org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo(PMAP_PROGRAM, PMAP_VERSION
                ) };
            //
            // We support both UDP and TCP-based transports for ONC/RPC portmap
            // calls, and these transports are bound to the well-known port 111.
            //
            transports = new org.acplt.oncrpc.server.OncRpcServerTransport[] { new org.acplt.oncrpc.server.OncRpcUdpServerTransport
                (this, PMAP_PORT, info, 32768), new org.acplt.oncrpc.server.OncRpcTcpServerTransport
                (this, PMAP_PORT, info, 32768) };
            //
            // Finally, we add ourself to the list of registered ONC/RPC servers.
            // This is just a convenience.
            //
            servers.Add(new org.acplt.oncrpc.OncRpcServerIdent(PMAP_PROGRAM, PMAP_VERSION, org.acplt.oncrpc.OncRpcProtocols
                .ONCRPC_TCP, PMAP_PORT));
            servers.Add(new org.acplt.oncrpc.OncRpcServerIdent(PMAP_PROGRAM, PMAP_VERSION, org.acplt.oncrpc.OncRpcProtocols
                .ONCRPC_UDP, PMAP_PORT));
            //
            // Determine all local IP addresses assigned to this host.
            // Once again, take care of broken JDKs, which can not handle
            // InetAdress.getLocalHost() properly. Sigh.
            //
            try
            {
                IPAddress loopback = IPAddress.Loopback;

                // Get host name
                string strHostName = Dns.GetHostName();
                IPAddress[] addrs = Dns.GetHostAddresses(strHostName);
                //
                // Check whether the loopback address is already included in
                // the address list for this host. If not, add it to the list.
                //
                bool loopbackIncluded = false;
                for (int idx = 0; idx < addrs.Length; ++idx)
                {
                    if (addrs[idx].Equals(loopback))
                    {
                        loopbackIncluded = true;
                        break;
                    }
                }
                if (loopbackIncluded)
                {
                    locals = addrs;
                }
                else
                {
                    locals = new IPAddress[addrs.Length + 1];
                    locals[0] = loopback;
                    System.Array.Copy(addrs, 0, locals, 1, addrs.Length);
                }
            }
            catch (SocketException)
            {
                // jmw need to debug this and see if it's the right exception to catch here
                //
                // Trouble getting all addresses for this host (which might
                // have been caused by some dumb security manager -- yeah, as
                // if managers were not dumb by definition), so fall back to
                // allowing only the loopback address.
                //
                locals = new IPAddress[1];
                locals[0] = IPAddress.Loopback;
            }
        }
コード例 #6
0
ファイル: jportmap.cs プロジェクト: wespday/RemoteTea.Net
        /// <summary>
        /// Create a new portmap instance, create the transport registration
        /// information and UDP and TCP-based transports, which will be bound
        /// later to port 111.
        /// </summary>
        /// <remarks>
        /// Create a new portmap instance, create the transport registration
        /// information and UDP and TCP-based transports, which will be bound
        /// later to port 111. The constructor does not start the dispatcher loop.
        /// </remarks>
        /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
        /// <exception cref="System.IO.IOException"></exception>
        public jportmap()
        {
            //
            // We only need to register one {progam, version}.
            //
            info = new org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo[] { new
                                                                                         org.acplt.oncrpc.server.OncRpcServerTransportRegistrationInfo(PMAP_PROGRAM, PMAP_VERSION
                                                                                                                                                       ) };
            //
            // We support both UDP and TCP-based transports for ONC/RPC portmap
            // calls, and these transports are bound to the well-known port 111.
            //
            transports = new org.acplt.oncrpc.server.OncRpcServerTransport[] { new org.acplt.oncrpc.server.OncRpcUdpServerTransport
                                                                                   (this, PMAP_PORT, info, 32768), new org.acplt.oncrpc.server.OncRpcTcpServerTransport
                                                                                   (this, PMAP_PORT, info, 32768) };
            //
            // Finally, we add ourself to the list of registered ONC/RPC servers.
            // This is just a convenience.
            //
            servers.Add(new org.acplt.oncrpc.OncRpcServerIdent(PMAP_PROGRAM, PMAP_VERSION, org.acplt.oncrpc.OncRpcProtocols
                                                               .ONCRPC_TCP, PMAP_PORT));
            servers.Add(new org.acplt.oncrpc.OncRpcServerIdent(PMAP_PROGRAM, PMAP_VERSION, org.acplt.oncrpc.OncRpcProtocols
                                                               .ONCRPC_UDP, PMAP_PORT));
            //
            // Determine all local IP addresses assigned to this host.
            // Once again, take care of broken JDKs, which can not handle
            // InetAdress.getLocalHost() properly. Sigh.
            //
            try
            {
                IPAddress loopback = IPAddress.Loopback;

                // Get host name
                string      strHostName = Dns.GetHostName();
                IPAddress[] addrs       = Dns.GetHostAddresses(strHostName);
                //
                // Check whether the loopback address is already included in
                // the address list for this host. If not, add it to the list.
                //
                bool loopbackIncluded = false;
                for (int idx = 0; idx < addrs.Length; ++idx)
                {
                    if (addrs[idx].Equals(loopback))
                    {
                        loopbackIncluded = true;
                        break;
                    }
                }
                if (loopbackIncluded)
                {
                    locals = addrs;
                }
                else
                {
                    locals    = new IPAddress[addrs.Length + 1];
                    locals[0] = loopback;
                    System.Array.Copy(addrs, 0, locals, 1, addrs.Length);
                }
            }
            catch (SocketException)
            {
                // jmw need to debug this and see if it's the right exception to catch here
                //
                // Trouble getting all addresses for this host (which might
                // have been caused by some dumb security manager -- yeah, as
                // if managers were not dumb by definition), so fall back to
                // allowing only the loopback address.
                //
                locals    = new IPAddress[1];
                locals[0] = IPAddress.Loopback;
            }
        }