/// <summary>
        /// Constructs and initializes an ONC/RPC client object, which can
        /// communicate with the portmapper at the given host using the
        /// speicified protocol.
        /// </summary>
        /// <remarks>
        /// Constructs and initializes an ONC/RPC client object, which can
        /// communicate with the portmapper at the given host using the
        /// speicified protocol.
        /// </remarks>
        /// <param name="host">Host where to contact the portmapper.</param>
        /// <param name="protocol">
        /// Protocol to use for contacting the portmapper. This
        /// can be either <code>OncRpcProtocols.ONCRPC_UDP</code> or
        /// <code>OncRpcProtocols.ONCRPC_TCP</code> (HTTP is currently
        /// not supported).
        /// </param>
        /// <param name="timeout">
        /// Timeout in milliseconds for connection operation. This
        /// parameter applies only when using TCP/IP for talking to the
        /// portmapper. A negative timeout indicates that the
        /// implementation-specific timeout setting of the JVM and java.net
        /// implementation should be used instead.
        /// </param>
        /// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
        /// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
        /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
        public OncRpcPortmapClient(IPAddress host, int protocol, int timeout)
        {
            switch (protocol)
            {
            case org.acplt.oncrpc.OncRpcProtocols.ONCRPC_UDP:
            {
                portmapClient = new org.acplt.oncrpc.OncRpcUdpClient(host, PMAP_PROGRAM, PMAP_VERSION
                                                                     , PMAP_PORT);
                break;
            }

            case org.acplt.oncrpc.OncRpcProtocols.ONCRPC_TCP:
            {
                portmapClient = new org.acplt.oncrpc.OncRpcTcpClient(host, PMAP_PROGRAM, PMAP_VERSION
                                                                     , PMAP_PORT, 0, timeout);
                // default buff size
                break;
            }

            default:
            {
                throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_UNKNOWNPROTO
                                                            ));
            }
            }
        }
 /// <summary>
 /// Creates a new <code>KscPackageUpdateEvent</code> object and
 /// initializes its state.
 /// </summary>
 /// <remarks>
 /// Creates a new <code>KscPackageUpdateEvent</code> object and
 /// initializes its state.
 /// </remarks>
 /// <param name="source">
 /// The
 /// <see cref="OncRpcUdpClient">ONC/RPC client object</see>
 /// which has
 /// fired this event.
 /// </param>
 /// <param name="replyAddress">Internetaddress of reply's origin.</param>
 /// <param name="procedureNumber">Procedure number of ONC/RPC call.</param>
 /// <param name="params">The ONC/RPC call resulting in this reply.</param>
 /// <param name="reply">The ONC/RPC reply itself.</param>
 public OncRpcBroadcastEvent(org.acplt.oncrpc.OncRpcUdpClient source, IPAddress
                             replyAddress, int procedureNumber, org.acplt.oncrpc.XdrAble @params, org.acplt.oncrpc.XdrAble
                             reply)
 {
     this.replyAddress    = replyAddress;
     this.procedureNumber = procedureNumber;
     this.@params         = @params;
     this.reply           = reply;
 }
Example #3
0
 /// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
 /// <exception cref="System.IO.IOException"></exception>
 public BroadcastClientTest()
 {
     //
     // Create a portmap client object, which can then be used to contact
     // the local ONC/RPC ServerTest test server.
     //
     org.acplt.oncrpc.OncRpcUdpClient client = new org.acplt.oncrpc.OncRpcUdpClient(java.net.InetAddress
                                                                                    .getByName("255.255.255.255"), 100000, 2, 111);
     //
     // Ping all portmappers in this subnet...
     //
     System.Console.Out.Write("pinging portmappers in subnet: ");
     client.setTimeout(5 * 1000);
     try
     {
         client.broadcastCall(0, org.acplt.oncrpc.XdrVoid.XDR_VOID, org.acplt.oncrpc.XdrVoid
                              .XDR_VOID, this);
     }
     catch (org.acplt.oncrpc.OncRpcException e)
     {
         System.Console.Out.WriteLine("method call failed unexpectedly:");
         Sharpen.Runtime.printStackTrace(e, System.Console.Out);
         System.Environment.Exit(1);
     }
     System.Console.Out.WriteLine("done.");
     //
     // Print addresses of all portmappers found...
     //
     for (int idx = 0; idx < portmappers.Count; ++idx)
     {
         System.Console.Out.WriteLine("Found: " + ((java.net.InetAddress)portmappers[idx])
                                      .getHostName() + " (" + ((java.net.InetAddress)portmappers[idx]).getHostAddress(
                                          ) + ")");
     }
     //
     // Release resources bound by portmap client object as soon as possible
     // so might help the garbage wo/man. Yeah, this is now a political
     // correct comment.
     //
     client.close();
     client = null;
 }
		/// <summary>
		/// Constructs and initializes an ONC/RPC client object, which can
		/// communicate with the portmapper at the given host using the
		/// speicified protocol.
		/// </summary>
		/// <remarks>
		/// Constructs and initializes an ONC/RPC client object, which can
		/// communicate with the portmapper at the given host using the
		/// speicified protocol.
		/// </remarks>
		/// <param name="host">Host where to contact the portmapper.</param>
		/// <param name="protocol">
		/// Protocol to use for contacting the portmapper. This
		/// can be either <code>OncRpcProtocols.ONCRPC_UDP</code> or
		/// <code>OncRpcProtocols.ONCRPC_TCP</code> (HTTP is currently
		/// not supported).
		/// </param>
		/// <param name="timeout">
		/// Timeout in milliseconds for connection operation. This
		/// parameter applies only when using TCP/IP for talking to the
		/// portmapper. A negative timeout indicates that the
		/// implementation-specific timeout setting of the JVM and java.net
		/// implementation should be used instead.
		/// </param>
		/// <exception cref="OncRpcException">if an ONC/RPC error occurs.</exception>
		/// <exception cref="System.IO.IOException">if an I/O error occurs.</exception>
		/// <exception cref="org.acplt.oncrpc.OncRpcException"></exception>
		public OncRpcPortmapClient(IPAddress host, int protocol, int timeout)
		{
			switch (protocol)
			{
				case org.acplt.oncrpc.OncRpcProtocols.ONCRPC_UDP:
				{
					portmapClient = new org.acplt.oncrpc.OncRpcUdpClient(host, PMAP_PROGRAM, PMAP_VERSION
						, PMAP_PORT, false);
					break;
				}

				case org.acplt.oncrpc.OncRpcProtocols.ONCRPC_TCP:
				{
					portmapClient = new org.acplt.oncrpc.OncRpcTcpClient(host, PMAP_PROGRAM, PMAP_VERSION
						, PMAP_PORT, 0, timeout);
					// default buff size
					break;
				}

				default:
				{
					throw (new org.acplt.oncrpc.OncRpcException(org.acplt.oncrpc.OncRpcException.RPC_UNKNOWNPROTO
						));
				}
			}
		}