Re: Sockets and Forwarding On Java



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
.



Relevant Pages

  • Re: Sockets and Forwarding On Java
    ... writing non-text characters from/to network sockets? ... sockets, and what came through one had to be copied over to the other, I ... stream while another one is writing to its input stream -- or with ... BTW I'd consider using a simple generic proxy like netcat, ...
    (comp.lang.java.help)
  • Re: Best inputstreams/outputstreams for sockets
    ... > Does anyone know what are the best inputstream/outputstreams for writing a ... > stream of ASCII text to sockets? ...
    (comp.lang.java.programmer)
  • Best inputstreams/outputstreams for sockets
    ... Does anyone know what are the best inputstream/outputstreams for writing a ... stream of ASCII text to sockets? ...
    (comp.lang.java.programmer)
  • Re: Linux, GUI & databases...
    ... >> find that many such computers that people run graphical applications on. ... >> developments on writing for machines without X. ... Linux has a lot to offer, but don't expect great technology from it. ...
    (comp.os.linux.development.apps)
  • Re: Unix domain socket leak in 6-STABLE
    ... > In my case the sockets are closed only if I stop the samba processes. ... I write the following perl script: ... ale firefox-bi 1323 11 stream -> ...
    (freebsd-stable)