Java Reference
In-Depth Information
public ServerSocket createServerSocket(int port, int backlog, InetAd-
dress address) throws IOException. Creates a ServerSocket on the
given port using the specified local address, which is useful when the
server has multiple IP addresses.
public ServerSocket createServerSocket() throws IOException. Creates
an unbound ServerSocket that can be bound using the bind() method of
the ServerSocket class.
The createServerSocket() methods of the ServerSocketFactory class have
identical parameters to the constructors in the java.net.ServerSocket class
discussed earlier in this chapter. When you are not using SSL, you can
either instantiate a ServerSocket object using one of its constructors (the
technique I showed you earlier in the SimpleServer program) or you can
use the ServerSocketFactory class and one of the createServerSocket()
methods. When you are using SSL, you must use a socket factory to obtain
a server socket.
Which technique you use for nonsecure sockets is a matter of choice, but
it is apparent from my experiences with other Java APIs that using a
factory class has its advantages, especially in making your code easier to
deploy on different platforms and in setting various properties of the
factory. For example, using a SocketFactory allows you to determine the
properties of a ServerSocket, such as its time-out value, without hard-
coding the values in your program.
After you have obtained an SSLServerSocket object using the factory, you
are now ready to initialize the server socket with any specific security settings.
The SSLServerSocket class extends java.net.ServerSocket, so you can invoke
those methods discussed earlier, such as accept() and close(), plus the methods
in SSLServerSocket, which include the following:
public void setEnabledCipherSuites(String [] suites). Sets the cipher
suites available for this connection. A cipher suite defines the security
algorithms for authentication, encryption, and key agreements, a process
referred to handshaking . The upcoming SSLServerDemo program shows
the common cipher suite values.
public String [] getSupportedCipherSuites(). Returns an array contain-
ing the cipher suites that can be enabled for this particular socket
connection.
Search WWH ::




Custom Search