Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #24185

Re: java proxy server problem

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail
From Michal Kleczek <michal_wytnijto@kleczek.org>
Newsgroups comp.lang.java.programmer
Subject Re: java proxy server problem
Date Mon, 27 May 2013 11:28:41 +0200
Organization Aioe.org NNTP Server
Lines 37
Message-ID <knv905$l16$1@speranza.aioe.org> (permalink)
References <a08b9724-2780-487b-bdc8-9cda348808a2@googlegroups.com>
NNTP-Posting-Host ZzNcjiVEyHSgCAKxRrAf8w.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120824 Thunderbird/15.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.java.programmer:24185

Show key headers only | View raw


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


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