What does this socket error mean?

Misa Amane

New Member
First of all thanks to everyone that answers questions on here. i have used this forum as a java bible. This is a homework problem. here is the assignment:Write a program in Java that uses sockets to connect to a web server on port 80, requests a web page using GET of the HTTP protocol, and displays the resulting HTMLNot sure if i am doing this right or not. I have a very limited understanding of java. Most of this is from tutorials i have been going through. any website links would be greatly appreciated alsohere is my error message\[code\]Exception in thread "main" java.lang.Error: Unresolved compilation problems: Type mismatch: cannot convert from java.net.Socket to SocketThe method getInputStream() is undefined for the type Socket\[/code\]here is my code\[code\]import java.io.*;import java.net.*;public class Server {public static void main(String[] args) throws Exception { Server SERVER = new Server(); SERVER.run();} public void run() throws Exception { ServerSocket one = new ServerSocket (80); //these are the two lines of code it is warning about Socket myskt = one.accept(); InputStreamReader IR = new InputStreamReader(myskt.getInputStream()); //end of warnings BufferedReader BR = new BufferedReader (IR); String message = BR.readLine(); System.out.println(message); if (message != null) { PrintStream PS = new PrintStream (System.out); PS.println ("Message Received"); } URL website = new URL("www.dogs.com"); URLConnection yc = website.openConnection(); BufferedReader in = new BufferedReader(new InputStreamReader( yc.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); one.close(); } // TODO Auto-generated method stub}\[/code\]
 
Back
Top