Search code examples
javaserial-porttelnet

How to create a telnet connection through Serial port?


I am trying to establish a telnet connection through a serial port in java. I am able to write to the port and confirmed that the data is written to the port using Serial port monitoring tool.

But I don't receive any response in turn.

I am using Java Simple Serial Connection Library/Jar (JSSC.jar)

Can anyone shed some light on this.


Solution

  • I used Java Simple Serial Connection Jar and established a telnet session by the following steps:

    1. Connect to Cisco router
    2. fired the telnet command ciscorouter>telnet xxx.xxx.xxx.xxx xxxx /source-interface ethernetX
    3. Once telnet opened just fired my request query and recieved the response.

    Note: For writing, I use:

        serialPort.writeString("command\r");`
    

    and:

        byte buffer[] = null;
        String  s = new String(buffer);
    

    Did not implement listeners as it caused lot of confusion.