Basic HTML version of Foils prepared 17 Nov 97

Foil 48 Socket from the Client Side

From Java Tutorial, July 1, 1996 CEWES Tutorial, CPS606, JSU Class CSC499 -- July 22-25 1997, Fall 97. by Nancy J. McCracken,Geoffrey C. Fox, Tom Scavo

Socket examples for Foil 48
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)
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 Wed Apr 1 1998