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) }; }
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) }; }
/// <summary> /// Process incomming remote procedure call requests from all specified /// transports. /// </summary> /// <remarks> /// Process incomming remote procedure call requests from all specified /// transports. To end processing and to shut the server down signal /// the /// <see cref="shutdownSignal">shutdownSignal</see> /// object. Note that the thread on which /// <code>run()</code> is called will ignore any interruptions and /// will silently swallow them. /// </remarks> /// <param name="transports"> /// Array of server transport objects for which /// processing of remote procedure call requests should be done. /// </param> public virtual void run(OncRpcServerTransport[] transports ) { int size = transports.Length; for (int idx = 0; idx < size; ++idx) { transports[idx].listen(); } // // Loop and wait for the shutdown flag to become signalled. If the // server's main thread gets interrupted it will not shut itself // down. It can only be stopped by signalling the shutdownSignal // object. // for (; ; ) { lock (shutdownSignal) { try { Monitor.Wait(shutdownSignal); break; } catch (System.Exception) { } } } }
/// <summary>Close all transports listed in a set of server transports.</summary> /// <remarks> /// Close all transports listed in a set of server transports. Only /// by calling this method processing of remote procedure calls by /// individual transports can be stopped. This is because every server /// transport is handled by its own thread. /// </remarks> /// <param name="transports">Array of server transport objects to close.</param> public virtual void Close(OncRpcServerTransport[] transports ) { int size = transports.Length; for (int idx = 0; idx < size; ++idx) { transports[idx].Close(); } }
/// <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; } }
/// <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; } }