EXCUSE ME HOW TO DO java proxy............socket handling!

M

mike

REGARD:


A -> B -> C
<- <-
A is client
B is proxy
C is server....

HOW TO WRITE PROGRAM TO RECEIVE DATA WHICH C TRANSFER TO B make a
dealing and then TRANSFER TO A?

THANK YOU VERY MUCH.....

BEST REGARDS
 
R

Rogan Dawes

mike said:
REGARD:


A -> B -> C
<- <-
A is client
B is proxy
C is server....

HOW TO WRITE PROGRAM TO RECEIVE DATA WHICH C TRANSFER TO B make a
dealing and then TRANSFER TO A?

THANK YOU VERY MUCH.....

BEST REGARDS

Not sure what you mean by "make a dealing".

I assume that you are talking about a HTTP Proxy server, that supports
the CONNECT method.

In order to communicate with C from A, A must open a socket to B (using
the port of the proxy software), send

CONNECT C:port HTTP/1.0\r\n
\r\n

on the Socket.getoutputStream()

read a response of the form:

HTTP/1.0 200 OK\r\n
Header1: x\r\n
Headern: x\r\n
\r\n

from the Socket.getInputStream(). At this point, once you have read the
last \r\n, you effectively have a direct connection to C, on the port
specified. You can wrap the socket's InputStream and OutputStream using
whatever other classes you want,or do whatever else you want to.

possible complications: The proxy may require authentication, or not
permit you to connect to C, or the particular port on C. In which case,
you will not receive a response "200 OK", rather a response starting
with 4xx. If this happens, you will not be able to connect to C.

Hope this helped.

Rogan
 
M

mike

A -> B -> CREGARDS:

i mean C reply a socket data flow to B and B get the socket flow and then
transfer the socket flow to A

At B

if the socket flow contain X.htm,Y.jpg,Z.img,.......

how can i get the target i want X.htm,and then make a handle to the X.htm

then put the X.htm back to the socket flow and then transfer the socket flow

to A ?....

THANK YOU VERY MUCH

BEST REGARDS
 
G

Gordon Beaton

i mean C reply a socket data flow to B and B get the socket flow and then
transfer the socket flow to A

At B

if the socket flow contain X.htm,Y.jpg,Z.img,.......

how can i get the target i want X.htm,and then make a handle to
the X.htm

then put the X.htm back to the socket flow and then transfer the
socket flow

to A ?....

The client connects to the proxy and makes a request.

The proxy connects to the server and makes the request on behalf of
the client.

The proxy now has two sockets - one to the client and one to the
server.

The proxy now loops. Everything that he reads from the server socket,
he writes to the client socket (and vice versa). When the proxy
reaches EOF on either of the sockets, he should close both of them.

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top