Basic HTML version of Foils prepared 18 May 97

Foil 37 Socket from the Client Side

From Java Tutorial - Spring 1997 Part 4: Multithreading, useful Java classes, I/O, Networking, and the future Peking Tutorial, Web Certificate -- Spring-Summer 1997. by Nancy J. McCracken,Geoffrey C. Fox


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.

in Table To:


© 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 Thu Jan 8 1998