Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat does this socket error mean?
    primarykey
    data
    text
    <p>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 and here is the assignment:</p> <blockquote> <p>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 HTML</p> </blockquote> <p>Not 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.</p> <p>Here is my error message:</p> <pre><code>Exception in thread "main" java.lang.Error: Unresolved compilation problems: Type mismatch: cannot convert from java.net.Socket to Socket The method getInputStream() is undefined for the type Socket </code></pre> <p>Here is my code:</p> <pre><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></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload