input and output streams

I am struggling with this, if any of you have any advice I would appreciate it.

I am creating a java server that can communicate with a client over tcp sockets and to a device through a serial port. I have have the TCP part all set up. I found this packet and code to be able to communicate through a serial port.

http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port

it works by itself, but I don't think I can make it work with my server because I am already using a system.in for the tcp portion of it. In the long run what I want to be able to do is take information from the socket connection, play with it a little bit, and then send it out the serial port to the device.

Is it possible to convert this code to instead of asking for input from the keyboard, to take a string that I can pass in from somewhere, or if something comes in on the serial port to write it to a string or something?

[954 byte] By [wjd4a] at [2007-11-26 19:58:58]
# 1

I don't understand the problem. Sockets give you their own Input- and

OutputStreams; the serial stuff gives you its own Input- and OutputStreams.

Where does that System.in come in? It isn't needed at all, i.e. read from

a socket InputStream, write it to a serial device's OutputStream.

kind regards,

Jos

JosAHa at 2007-7-9 22:55:16 > top of Java-index,Java Essentials,New To Java...
# 2

Sorry I was so vague.

this code that i found on the website, creates a connection with the serial port, then it waits for input from the keyboard. once that input comes in, it sends out that stuff through the serial port. I want it to instead of wanting for input from the keyboard, to check to see if there is something in a string or something, if there is write it out to the serial port.

Basically instead of having a listener constantly waiting for input from the keyboard, be able to call a method from the rest of my program to send stuff out the serial port.

wjd4a at 2007-7-9 22:55:16 > top of Java-index,Java Essentials,New To Java...
# 3
Sure, you can do that. But I don't see the problem. If you don't need the code that reads from System.in then delete that code. If you need some other code that calls a method then put that code in.
DrClapa at 2007-7-9 22:55:16 > top of Java-index,Java Essentials,New To Java...
# 4
that is where I am stuck, I don't understand well enough what they are doing in the code to be able to modify it that much.The nested classes, the super, and the this.doesn't seem to sit well with me.
wjd4a at 2007-7-9 22:55:17 > top of Java-index,Java Essentials,New To Java...