[ Contact ] [ Links ] [ Previous : 56 / 60 : JAVA TCP/IP Socket Implementation ] [ Up ] [ Next : 58 / 60 : JAVA TCP/IP Socket Implementation ]

JAVA TCP/IP Socket Implementation (4)

Client Actions

Close the socket

  1. Instantiate a Socket object
  2. Communicate with server
    1. Send data/requests
    2. Receive data/replys
  3. Close the socket
  • Close the socket when finished communicating
  • Both client and server must close their sockets to completely tear down the connection
  • Server must also close down the ServerSocket when no more client connections are expected
try	{
	sock.close();
}
catch(IOException ioe) {
	System.out.println("Close error: " + ioe.getMessage());
}

// Again, close() needs to be called on both sides of the connection, and the server should 
// also be sure to close() the ServerSocket when it no longer wishes to accept client
// connections.
eScience
< Internetworked VR : Networking >
[ Contact ] [ Links ] [ Previous : 56 / 60 : JAVA TCP/IP Socket Implementation ] [ Up ] [ Next : 58 / 60 : JAVA TCP/IP Socket Implementation ]

See the "Links" link above to find out the sources of the proposed informations
Pascal Vuylsteker / eScience / Computer Science / ANU
Last modified: 22/3/2005
TOC - Print
Send your comments at :
<pvk@vuylsteker.net>