Link to home
Start Free TrialLog in
Avatar of Sdurrani
Sdurrani

asked on

Server sockts

Hi there
I am working on the following code and I cannot seem to get it to compile please advise.
import java.io.*;
import java.net.*;
import java.util.Scanner;
 
class GetDataFromWebServer {
 
GetDataFromWebServer () throws IOException;
 
 
String address = "http://www.curl.com";
URL u = new URL (address);
URLConnection connection = u.openConnection();
 
 
final int HTTP_PORT  = 80;
 
 
Socket  s = new Socket() ;
 
 
InputStream ins = s.getInputStream();
 
 
OutputStream outs = s.getOutputStream();
 
 
Scanner in = new Scanner (ins);
 
 
PrintWriter out = new PrintWriterv("outs");
 
 
String command = "GET / HTTP/1.0\n\n";
out.print(command);
 
 
 
out.flush ();
 
 
while (in.hasNextLine()) {
String line = in.nextLine();
out.println (line);
}
 
 
s.close;
 
public sProxy-Connection: keep-alive Cache-Control: max-age=0 tic void main (String[] args) {
try {
GetDataFromWebServer g = new GetDataFromWebServer();
}
catch (Exception e) {
}
}

Open in new window

SOLUTION
Avatar of swapnil001
swapnil001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial