D
dietmar
my server programm sends a response (e.g. HTML-code) to the requested
web-browser-client (firefox or IE).
It works, but only when the request data in the input-stream from the
client-socket are read.
Why??
Dietmar
see the example code:
....
ServerSocket server = new ServerSocket(80); // any other port(9991);
Socket client=server.accept();
String ip=client.getInetAddress().toString();
// Read request from client-socket input-stream
// if the entire read code is marked out as commentar,
// it doesn't worked.
InputStream is = client.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuffer request= new StringBuffer();
while ((r=br.readLine()).length()!=0)
{
request.append(r + "\n");
}
// Write response to client
OutputStream os = client.getOutputStream();
Date date=new Date();
String s= "<html> <head><title>Hallo Web</title></head>"+
"<body><h1>HELLO" + ip + " im WEB</h1>"+"</body>";
byte b[]=s.getBytes();
os.write(b);
....
IE-call: http:\\localhost
web-browser-client (firefox or IE).
It works, but only when the request data in the input-stream from the
client-socket are read.
Why??
Dietmar
see the example code:
....
ServerSocket server = new ServerSocket(80); // any other port(9991);
Socket client=server.accept();
String ip=client.getInetAddress().toString();
// Read request from client-socket input-stream
// if the entire read code is marked out as commentar,
// it doesn't worked.
InputStream is = client.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuffer request= new StringBuffer();
while ((r=br.readLine()).length()!=0)
{
request.append(r + "\n");
}
// Write response to client
OutputStream os = client.getOutputStream();
Date date=new Date();
String s= "<html> <head><title>Hallo Web</title></head>"+
"<body><h1>HELLO" + ip + " im WEB</h1>"+"</body>";
byte b[]=s.getBytes();
os.write(b);
....
IE-call: http:\\localhost