import java.net.*; import java.io.* ; class webclient{ public static void main (String args[]) { Socket RemoteHostConnect ; InputStream RemoteInput ; OutputStream RemoteOutput ; String HostName = "www.unca.edu" ; int port = 80 ; try { RemoteHostConnect = new Socket(HostName, port) ; RemoteInput = RemoteHostConnect.getInputStream() ; RemoteOutput = RemoteHostConnect.getOutputStream() ; } catch ( IOException ioe ) { System.out.println("Cannot connect to " + HostName) ; return ; } try { int rc ; byte[] fromServ = new byte[1000] ; byte[] toServ = "GET /index.html HTTP/1.0\r\n\r\n".getBytes() ; RemoteOutput.write(toServ) ; while ((rc = RemoteInput.read(fromServ)) > 0) System.out.write(fromServ, 0, rc) ; } catch ( IOException ioe ) { System.out.println("Failure reading from socket") ; } } }