Basic HTML version of Foils prepared Sept 21 1998

Foil 48 Socket from the Client Side

From Java Tutorial 98- 4: Multi-Treading, Useful Java Classes, I/O and Networking NAVO Tutorial -- Sept 23 1998. by Geoffrey C. Fox, Nancy McCracken

Socket examples for Foil 48
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.



© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998