Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #24185
| From | Michal Kleczek <michal_wytnijto@kleczek.org> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: java proxy server problem |
| Date | 2013-05-27 11:28 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <knv905$l16$1@speranza.aioe.org> (permalink) |
| References | <a08b9724-2780-487b-bdc8-9cda348808a2@googlegroups.com> |
On 2013-05-24 13:12, mcheung63@gmail.com wrote:
> Dear All
> My proxy server just work in one level forward, That mean vncviewer->my proxy server->vnc server works.
> But for two levels forward, vncviewer->my proxy server->my proxy server > vncserver doesn't work, so why?
>
> public class SimpleProxyServer {
> public static void main(String[] args) throws IOException {
> try {
> String host = "210.5.164.14";
> int remoteport = 5999;
> int localport = 1234;
I assume your proxies are run on different hosts (so they can both bind
to port 1234).
Your first proxy connects to port 5999 and the second listens on port
1234. They both connect to the target server.
> // Start the client-to-server request thread running
> t.start();
>
> // Read the server's responses
> // and pass them back to the client.
> int bytesRead;
> try {
> while ((bytesRead = streamFromServer.read(reply)) != -1) {
> streamToClient.write(reply, 0, bytesRead);
> streamToClient.flush();
> }
> } catch (IOException e) {
> }
Here you are blocking accepting new connections.
Server-to-client relay should be done in a dedicated thread such as
client-to-server.
--
Michal
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
java proxy server problem mcheung63@gmail.com - 2013-05-24 04:12 -0700
Re: java proxy server problem Arne Vajhøj <arne@vajhoej.dk> - 2013-05-24 22:01 -0400
Re: java proxy server problem Peter Cheung <cmk128@gmail.com> - 2013-05-26 20:22 -0700
Re: java proxy server problem Arne Vajhøj <arne@vajhoej.dk> - 2013-05-27 12:47 -0400
Re: java proxy server problem Michal Kleczek <michal_wytnijto@kleczek.org> - 2013-05-27 11:28 +0200
csiph-web