Socket from the Client Side
A Java applet or application can open a socket to a Java server application through the Socket class (or any other running program).
- Socket t = new Socket("internet host name", port)
- or Socket t = new Socket(this.getCodeBase().getHost(), port)
The latter form is useful for applets as the applet can only use a socket to a server application running on the web host machine that the applet code was downloaded from.
Sockets have methods getInputStream and getOutputStream which can be used for communication. Note that both communication directions are possible at the same time on a socket.