/// <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); }
/// <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); }