1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net;
  17. import java.net.DatagramSocket;
  18. import java.net.InetAddress;
  19. import java.net.SocketException;
  20. /***
  21. * The DatagramSocketFactory interface provides a means for the
  22. * programmer to control the creation of datagram sockets and
  23. * provide his own DatagramSocket implementations for use by all
  24. * classes derived from
  25. * <a href="org.apache.commons.net.DatagramSocketClient.html">
  26. * DatagramSocketClient </a>.
  27. * This allows you to provide your own DatagramSocket implementations and
  28. * to perform security checks or browser capability requests before
  29. * creating a DatagramSocket.
  30. * <p>
  31. * <p>
  32. * @author Daniel F. Savarese
  33. ***/
  34. public interface DatagramSocketFactory
  35. {
  36. /***
  37. * Creates a DatagramSocket on the local host at the first available port.
  38. * <p>
  39. * @exception SocketException If the socket could not be created.
  40. ***/
  41. public DatagramSocket createDatagramSocket() throws SocketException;
  42. /***
  43. * Creates a DatagramSocket on the local host at a specified port.
  44. * <p>
  45. * @param port The port to use for the socket.
  46. * @exception SocketException If the socket could not be created.
  47. ***/
  48. public DatagramSocket createDatagramSocket(int port) throws SocketException;
  49. /***
  50. * Creates a DatagramSocket at the specified address on the local host
  51. * at a specified port.
  52. * <p>
  53. * @param port The port to use for the socket.
  54. * @param laddr The local address to use.
  55. * @exception SocketException If the socket could not be created.
  56. ***/
  57. public DatagramSocket createDatagramSocket(int port, InetAddress laddr)
  58. throws SocketException;
  59. }