• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to write telnet server like program?

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Sockets and Internet Protocols...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic