Creating and Using Sockets
Creating and Using Sockets
JAVA SOCKETS:
By P.Vinitha
Sockets and Ports
In order to communicate with a remote host
the Java client must first create a Socket,
which will establish the TCP connection.
While establishing the connection a host name
import java.net.*;
import java.io.*;
class readurl {
public static void main(String a[])throws Exception {
BufferedReader br1=new BufferedReader(new
InputStreamReader(System.in));
String filename;
System.out.print("Enter the webpage address:");
filename=br1.readLine();
URL myurl=new URL(filename);
InputStream in=myurl.openStream();
BufferedReader br=new BufferedReader(new
InputStreamReader(in));
String str;
while((str=br.readLine())!=null)
System.out.println(str);
br.close();
}
}