C
christian.kleegrewe
Hi all,
I try to write a HTTP proxy using java.net.ServerSocket class, but I
do not understand the behaviour of the accept call.
Here is the part of the code where the ServerSocket is created and
accept is called.
-->
ServerSocket s = new ServerSocket (localport);
while (true) {
Socket c = null;
try {
display("listening...");
c = s.accept();
if (c != null) {
byte r_in[] = new byte[256];
String request = new String();
InputStream in = c.getInputStream();
-->
I am testing the code with an opera web browser that has configured my
own proxy as web proxy. What happens no is a little bit confusing. The
server starts correctly and "listening..." is pronted on the console
but when I type in an URL in the address bar and press enter nothing
happens. After terminating the request by pressing the X button in the
navigation bar the accept returns and the URL is retrieved by the
proxy but not transmitted to the web browser since there is no
connection any more after the X button has been pressed.
Is there anybody who can help me with this behaviour? As far as I
suppose the accept should return immediately after I typed in the URL
and pressed the load or go button.
I am using windows XP SP2 as operating system and java 1.507 as jdk
thanks in advance Christian
I try to write a HTTP proxy using java.net.ServerSocket class, but I
do not understand the behaviour of the accept call.
Here is the part of the code where the ServerSocket is created and
accept is called.
-->
ServerSocket s = new ServerSocket (localport);
while (true) {
Socket c = null;
try {
display("listening...");
c = s.accept();
if (c != null) {
byte r_in[] = new byte[256];
String request = new String();
InputStream in = c.getInputStream();
-->
I am testing the code with an opera web browser that has configured my
own proxy as web proxy. What happens no is a little bit confusing. The
server starts correctly and "listening..." is pronted on the console
but when I type in an URL in the address bar and press enter nothing
happens. After terminating the request by pressing the X button in the
navigation bar the accept returns and the URL is retrieved by the
proxy but not transmitted to the web browser since there is no
connection any more after the X button has been pressed.
Is there anybody who can help me with this behaviour? As far as I
suppose the accept should return immediately after I typed in the URL
and pressed the load or go button.
I am using windows XP SP2 as operating system and java 1.507 as jdk
thanks in advance Christian