1 |
A Java applet or application can open a socket to a Java server application through the Socket class.
-
Socket t = new Socket("internet host name", port)
|
2 |
or Socket t = new Socket(this.getCodeBase().getHost(), port)
|
3 |
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.
|
4 |
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.
|