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