Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Java : Education - Tutorials
Using JSSE for secure socket communication
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
5. Using JSSE sockets
  


Nonsecure sockets: A review page 2 of 11


The following code fragment is typical for initiating a socket connection. This example creates a new Socket connection to port port at the remote computer host:


Socket socket = new Socket( host, port );

Similarly, the following code demonstrates how we listen for incoming connections. This example creates a ServerSocket listening on port port, and then enters an infinite loop, accepting and processing incoming connections:


ServerSocket serverSocket = new ServerSocket( port );
while (true) {
    Socket socket = serverSocket.accept();
    doSomethingWithNewConnection( socket );
}

Secure sockets work in a very similar manner, but before we can implement them for our example we must complete several steps. We'll go over these steps in the panels that follow.


Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact