Guest_imported
New member
- Jan 1, 1970
- 0
hi everybody,
I tried a simple telnet to port 80 to a webserver an I tape the lines below:
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Language: fr
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
Host: 172.16.0.2
Connection: Keep-Alive
then the server reply to me without problem and give me the default page like this:
HTTP/1.1 200 OK
Server: Microsoft-IIS/4.0
Content-Location: Date: Thu, 04 Oct 2001 18:49:22 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Tue, 18 Sep 2001 22:37:07 GMT
ETag: "7052b6729240c11:13fb"
Content-Length: 37
but when I use a java class that make the same thing I've got no response from the server.
this is the program:
import java.io.*;
import java.net.*;
public class WebClient
{
public static void main(String args[])
{
try{
String aff;
Socket conn = new Socket("172.16.0.1", 80);
OutputStream l1 = conn.getOutputStream();
InputStream l2 = conn.getInputStream();
DataOutputStream ecr = new DataOutputStream(l);
BufferedReader lire = new BufferedReader(new InputStreamReader(l2));
ecr.writeChars("GET / HTTP/1.1"
System.out.println("ok 1"
ecr.writeChars("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
"
System.out.println("ok 2"
ecr.writeChars("Accept-Language: fr"
System.out.println("ok 3"
ecr.writeChars("Accept-Encoding: gzip, deflate"
System.out.println("ok 4"
ecr.writeChars("User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)"
System.out.println("ok 5"
ecr.writeChars ("Host: 172.16.0.2"
System.out.println("ok 6"
ecr.writeChars("Connection: Keep-Alive"
System.out.println("ok 7"
aff=lire.readLine();
System.out.println(aff);
System.out.println("FINE "
}
catch(Exception e) {System.out.println("error"}
}
}
the output is :
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
It seem that the socket is blocked and can't read the inputsream.
what's this strange problem?
I tried a simple telnet to port 80 to a webserver an I tape the lines below:
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Accept-Language: fr
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)
Host: 172.16.0.2
Connection: Keep-Alive
then the server reply to me without problem and give me the default page like this:
HTTP/1.1 200 OK
Server: Microsoft-IIS/4.0
Content-Location: Date: Thu, 04 Oct 2001 18:49:22 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Tue, 18 Sep 2001 22:37:07 GMT
ETag: "7052b6729240c11:13fb"
Content-Length: 37
but when I use a java class that make the same thing I've got no response from the server.
this is the program:
import java.io.*;
import java.net.*;
public class WebClient
{
public static void main(String args[])
{
try{
String aff;
Socket conn = new Socket("172.16.0.1", 80);
OutputStream l1 = conn.getOutputStream();
InputStream l2 = conn.getInputStream();
DataOutputStream ecr = new DataOutputStream(l);
BufferedReader lire = new BufferedReader(new InputStreamReader(l2));
ecr.writeChars("GET / HTTP/1.1"
System.out.println("ok 1"
ecr.writeChars("Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
"
System.out.println("ok 2"
ecr.writeChars("Accept-Language: fr"
System.out.println("ok 3"
ecr.writeChars("Accept-Encoding: gzip, deflate"
System.out.println("ok 4"
ecr.writeChars("User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)"
System.out.println("ok 5"
ecr.writeChars ("Host: 172.16.0.2"
System.out.println("ok 6"
ecr.writeChars("Connection: Keep-Alive"
System.out.println("ok 7"
aff=lire.readLine();
System.out.println(aff);
System.out.println("FINE "
}
catch(Exception e) {System.out.println("error"}
}
}
the output is :
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
It seem that the socket is blocked and can't read the inputsream.
what's this strange problem?