1 /* 2 * Conditions Of Use 3 * 4 * This software was developed by employees of the National Institute of 5 * Standards and Technology (NIST), an agency of the Federal Government. 6 * Pursuant to title 15 Untied States Code Section 105, works of NIST 7 * employees are not subject to copyright protection in the United States 8 * and are considered to be in the public domain. As a result, a formal 9 * license is not needed to use the software. 10 * 11 * This software is provided by NIST as a service and is expressly 12 * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED 13 * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF 14 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT 15 * AND DATA ACCURACY. NIST does not warrant or make any representations 16 * regarding the use of the software or the results thereof, including but 17 * not limited to the correctness, accuracy, reliability or usefulness of 18 * the software. 19 * 20 * Permission to use this software is contingent upon your acceptance 21 * of the terms of this agreement 22 * 23 * . 24 * 25 */ 26 package gov.nist.core.net; 27 28 import java.io.IOException; 29 import java.net.DatagramSocket; 30 import java.net.InetAddress; 31 import java.net.ServerSocket; 32 import java.net.Socket; 33 import java.net.SocketException; 34 35 // Added by Daniel J. Martinez Manzano <dani@dif.um.es> 36 import javax.net.ssl.SSLServerSocket; 37 import javax.net.ssl.SSLSocket; 38 39 40 /** 41 * basic interface to the network layer 42 * 43 * @author m.andrews 44 * 45 */ 46 public interface NetworkLayer { 47 48 /** 49 * Creates a server with the specified port, listen backlog, and local IP address to bind to. 50 * comparable to "new java.net.ServerSocket(port,backlog,bindAddress);" 51 * 52 * @param port 53 * @param backlog 54 * @param bindAddress 55 * @return the server socket 56 */ createServerSocket(int port, int backlog, InetAddress bindAddress)57 public ServerSocket createServerSocket(int port, int backlog, 58 InetAddress bindAddress) throws IOException; 59 60 /** 61 * Creates an SSL server with the specified port, listen backlog, and local IP address to bind to. 62 * Added by Daniel J. Martinez Manzano <dani@dif.um.es> 63 * 64 * @param port 65 * @param backlog 66 * @param bindAddress 67 * @return the server socket 68 */ createSSLServerSocket(int port, int backlog, InetAddress bindAddress)69 public SSLServerSocket createSSLServerSocket(int port, int backlog, 70 InetAddress bindAddress) throws IOException; 71 72 /** 73 * Creates a stream socket and connects it to the specified port number at the specified IP address. 74 * comparable to "new java.net.Socket(address, port);" 75 * 76 * @param address 77 * @param port 78 * @return the socket 79 */ createSocket(InetAddress address, int port)80 public Socket createSocket(InetAddress address, int port) throws IOException; 81 82 /** 83 * Creates a stream socket and connects it to the specified port number at the specified IP address. 84 * comparable to "new java.net.Socket(address, port,localaddress);" 85 * 86 * @param address 87 * @param port 88 * @param localAddress 89 * @return the socket 90 */ createSocket(InetAddress address, int port, InetAddress localAddress)91 public Socket createSocket(InetAddress address, int port, InetAddress localAddress) throws IOException; 92 93 /** 94 * Creates a new Socket, binds it to myAddress:myPort and connects it to 95 * address:port. 96 * 97 * @param address the InetAddress that we'd like to connect to. 98 * @param port the port that we'd like to connect to 99 * @param myAddress the address that we are supposed to bind on or null 100 * for the "any" address. 101 * @param myPort the port that we are supposed to bind on or 0 for a random 102 * one. 103 * 104 * @return a new Socket, bound on myAddress:myPort and connected to 105 * address:port. 106 * @throws IOException if binding or connecting the socket fail for a reason 107 * (exception relayed from the correspoonding Socket methods) 108 */ createSocket(InetAddress address, int port, InetAddress myAddress, int myPort)109 public Socket createSocket(InetAddress address, int port, 110 InetAddress myAddress, int myPort) 111 throws IOException; 112 113 /** 114 * Creates a stream SSL socket and connects it to the specified port number at the specified IP address. 115 * Added by Daniel J. Martinez Manzano <dani@dif.um.es> 116 * 117 * @param address 118 * @param port 119 * @return the socket 120 */ createSSLSocket(InetAddress address, int port)121 public SSLSocket createSSLSocket(InetAddress address, int port) throws IOException; 122 123 /** 124 * Creates a stream SSL socket and connects it to the specified port number at the specified IP address. 125 * Added by Daniel J. Martinez Manzano <dani@dif.um.es> 126 * 127 * @param address 128 * @param port 129 * @param localAddress -- my address. 130 * @return the socket 131 */ createSSLSocket(InetAddress address, int port, InetAddress localAddress)132 public SSLSocket createSSLSocket(InetAddress address, int port, InetAddress localAddress) throws IOException; 133 134 /** 135 * Constructs a datagram socket and binds it to any available port on the local host machine. 136 * comparable to "new java.net.DatagramSocket();" 137 * 138 * @return the datagram socket 139 */ createDatagramSocket()140 public DatagramSocket createDatagramSocket() throws SocketException; 141 142 /** 143 * Creates a datagram socket, bound to the specified local address. 144 * comparable to "new java.net.DatagramSocket(port,laddr);" 145 * 146 * @param port 147 * @param laddr 148 * @return the datagram socket 149 */ createDatagramSocket(int port, InetAddress laddr)150 public DatagramSocket createDatagramSocket(int port, InetAddress laddr) 151 throws SocketException; 152 153 } 154