Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to write telnet server like program?

 
Siegfried Heintze
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to write a program similar to a telnet server. A telnet server
asynchronously reads data from a socket and writes it to a
sub-process, and asynchronously reads data from the subprocess and
writes to a socket. My program needs to replace the subprocess with a
serial port.

The telnet server cannot anticipate when data will arrive from the
socket. Neither can it anticipate when data will arrive from the
subprocess.

How can I write a similar OS vendor neutral program using Java or
Groovy or Jython, except, instead reading and writing to a process, I
read and write to serial port? Can I do this with a single thread? How
do I read and write to a serial port? Can anyone point me to some
sample code for serial port I/O?

Thanks,
Siegfried
 
Mark Griffin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like you are developing a front end for a serial device.

The "front end" is a socket server. It accepts socket connections from clients and passes information back and forth between the clients and the serial attached device.

If that's the jist of it then you need two things to get started.

1) an example socket server program. Simple ones that just create a Server Socket, accpet connections, and pass the connection off to a new thread are easy to find.

2) a set of classes for communication with a serial port. That's a little trickier - there are payware SDKs for this. Maybe you can find something on sourceforge.

ALTERNATIVELY you could use a servlet container like Tomcat to handle the client connections and just write a servlet that talks to the serial attached device. You still need a serial port SDK.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Sockets and Internet Protocols...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic