Re: Sockets and Forwarding On Java
- From: Hal Vaughan <hal@xxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 08 Mar 2006 10:21:26 -0500
Gordon Beaton wrote:
On Wed, 08 Mar 2006 01:23:15 -0500, Hal Vaughan wrote:
1) [...] Are there any side effects or problems in reading or
writing non-text characters from/to network sockets?
No, in fact bytes are to be preferred. Anything else involves some
kind of conversion, but your proxy should handle the data as little as
possible.
Good. That's a relief.
2) All the examples are synchronized. They write to the socket, wait for[...]
output, then write again and wait for output again. Since I had two
sockets, and what came through one had to be copied over to the other, I
was planning on using two asynchronous threads.
Is there a problem with one thread reading the socket's output
stream while another one is writing to its input stream -- or with
other async communication?
The socket consists of two streams - one in each direction - and they
are independent of one another. There is no need to synchronize reads
from one with writes to the other. Using a thread per direction is the
way to go (unless you choose to use a Selector, which would let you do
away with the extra thread).
I hadn't heard of Selectors, so I'll look into that. Thanks for mentioning
it.
BTW I'd consider using a simple generic proxy like netcat, or the
port-forwarding facility ssh provides. No need to reinvent the wheel.
I've looked into it. I spent all day yesterday getting stunnel4 to work,
forwarding from a WinXP system to my Linux box. (The docs regarding
certificate location specs in the conf file are off -- you need to specify
the full path to each cert.) Then I found issues with it forwarding on
Linux when I tried that. It seems every tunneling program I find has
limits. I hadn't heard of netcat, but on the homepage it lists the OSes it
works with, and it's only *nix, no windows.
I'm amazed at how hard it has been to find a program that'll do what I need,
which is just simple tunneling. The one advantage I can see to writing my
own is that it'll be a class that is easier to integrate into my program
than a 3rd party program that needs its own libs and has to be run
separately.
There's also another issue that might be a problem, but I'm having trouble
getting info on Google for it (a lot of noise -- hard to restrict the
search). It seems there are restrictions on Linux for using ports under
1024 by non-root users. If anyone has info on this or a good link, I'd
appreciate it.
Thanks!
Hal
.
- Follow-Ups:
- Re: Sockets and Forwarding On Java
- From: Gordon Beaton
- Re: Sockets and Forwarding On Java
- From: Paul Bilnoski
- Re: Sockets and Forwarding On Java
- From: Gordon Beaton
- Re: Sockets and Forwarding On Java
- References:
- Sockets and Forwarding On Java
- From: Hal Vaughan
- Re: Sockets and Forwarding On Java
- From: Gordon Beaton
- Sockets and Forwarding On Java
- Prev by Date: Re: Sorting elements of a vector in java
- Next by Date: Re: Sorting elements of a vector in java
- Previous by thread: Re: Sockets and Forwarding On Java
- Next by thread: Re: Sockets and Forwarding On Java
- Index(es):
Relevant Pages
|