    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
    018package org.apache.commons.net;
    019
    020import java.net.DatagramSocket;
    021import java.net.InetAddress;
    022import java.net.SocketException;
    023
    024/***
    025 * DefaultDatagramSocketFactory implements the DatagramSocketFactory
    026 * interface by simply wrapping the java.net.DatagramSocket
    027 * constructors.  It is the default DatagramSocketFactory used by
    028 * {@link org.apache.commons.net.DatagramSocketClient}
    029 *  implementations.
    030 * <p>
    031 * <p>
    032 * @see DatagramSocketFactory
    033 * @see DatagramSocketClient
    034 * @see DatagramSocketClient#setDatagramSocketFactory
    035 ***/
    036
    037public class DefaultDatagramSocketFactory implements 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//    @Override
    046    public DatagramSocket createDatagramSocket() throws SocketException
    047    {
    048        return new DatagramSocket();
    049    }
    050
    051    /***
    052     * Creates a DatagramSocket on the local host at a specified port.
    053     * <p>
    054     * @param port The port to use for the socket.
    055     * @exception SocketException If the socket could not be created.
    056     ***/
    057//    @Override
    058    public DatagramSocket createDatagramSocket(int port) throws SocketException
    059    {
    060        return new DatagramSocket(port);
    061    }
    062
    063    /***
    064     * Creates a DatagramSocket at the specified address on the local host
    065     * at a specified port.
    066     * <p>
    067     * @param port The port to use for the socket.
    068     * @param laddr  The local address to use.
    069     * @exception SocketException If the socket could not be created.
    070     ***/
    071//    @Override
    072    public DatagramSocket createDatagramSocket(int port, InetAddress laddr)
    073    throws SocketException
    074    {
    075        return new DatagramSocket(port, laddr);
    076    }
    077}