001 /*
002 * Copyright 2001-2005 The Apache Software Foundation
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.apache.commons.net;
017
018 import java.net.DatagramSocket;
019 import java.net.InetAddress;
020 import java.net.SocketException;
021
022 /***
023 * The DatagramSocketFactory interface provides a means for the
024 * programmer to control the creation of datagram sockets and
025 * provide his own DatagramSocket implementations for use by all
026 * classes derived from
027 * {@link org.apache.commons.net.DatagramSocketClient}
028 * .
029 * This allows you to provide your own DatagramSocket implementations and
030 * to perform security checks or browser capability requests before
031 * creating a DatagramSocket.
032 * <p>
033 * <p>
034 * @author Daniel F. Savarese
035 ***/
036
037 public interface DatagramSocketFactory
038 {
039
040 /***
041 * Creates a DatagramSocket on the local host at the first available port.
042 * <p>
043 * @exception SocketException If the socket could not be created.
044 ***/
045 public DatagramSocket createDatagramSocket() throws SocketException;
046
047 /***
048 * Creates a DatagramSocket on the local host at a specified port.
049 * <p>
050 * @param port The port to use for the socket.
051 * @exception SocketException If the socket could not be created.
052 ***/
053 public DatagramSocket createDatagramSocket(int port) throws SocketException;
054
055 /***
056 * Creates a DatagramSocket at the specified address on the local host
057 * at a specified port.
058 * <p>
059 * @param port The port to use for the socket.
060 * @param laddr The local address to use.
061 * @exception SocketException If the socket could not be created.
062 ***/
063 public DatagramSocket createDatagramSocket(int port, InetAddress laddr)
064 throws SocketException;
065 }