JAVA Socket Communications


#1

hi there

anybody knows anything about using JAVA Socket API's i am having some problems .

i want to communicate with the yahoo but it returns exceptions

can anybody hellp


#2

^ Post code. What exactly are you doing and what exactly is the exception?


#3

import java.net.*;

import java.io.*;

import java.util.Scanner;

import static java.lang.System.out;

public class Client {

public static void main(String[] args) {

String url="www.yahoo.com";

int port=80;

Scanner scan=new Scanner(System.in);

// Socket s;

try

{

//out.println("Please Enter the URL");

// url=scan.next();

Socket s=new Socket(url,port);

System.out.print("HI1");

InputStream inputStream=s.getInputStream();

InputStreamReader isr=new InputStreamReader(inputStream);

BufferedReader in =new BufferedReader(isr);

OutputStream outputStream=s.getOutputStream();

OutputStreamWriter osr=new OutputStreamWriter(outputStream);

PrintWriter out=new PrintWriter(osr);

out.println("You Entered: "+url);

out.flush();

System.out.println(in.readLine());

System.out.print("HI");

}

catch(Exception e){e.printStackTrace();}

}

}


#4

oh sorry it working ok now

but the problem is that i want to display the HTML on the console but it displays only the following thing

Not Found

any suggestions


#5

um........you want to display HTML........ on...... "Console"???!!??!! :/


#6

yup thats the problemo


#7

i mean i donot want to render the HTML just text should be displayed