Results 1 to 6 of 6

Thread: Break a telnet connection

  1. #1
    Join Date
    Dec 2009
    Posts
    204

    Break a telnet connection

    Hello,
    In a telnet connection I have sent a break request to terminate the connection. Here is my code
    Code:
    	OutputStream getOutputStream ust =();
    ...
            ust.write(TelnetCommand.getCommand(TelnetCommand.BREAK));
            ust.flush();
    ...
    Though I have done it, it is not working. Any other solution than this will be appreciated. Thanks in advance.
    Last edited by Ash maker; 29-01-2010 at 12:14 PM.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Break a telnet connection

    Hello,
    Which library do you use? What's wrong? What is the code producing the error? So many questions whose answers are important to help. I think you are not precise with the question. What exactly do you want, I mean how you want your program to work. And I think this is just the part of your code. Post the full or the part of the code which contains the logic of the code.

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: Break a telnet connection

    Hello,
    Even I am trying something like this. I use the library commons-net jakarta, actually I'm not getting an error, the server-cons with which I should return match a specific answer, but it returns me nothing. It works in command line via a telnet client.
    This is what I test
    Code:
    PrintStream str = new PrintStream(getOutputStream());
    ..
       str.System.out.println(TelnetCommand.getCommand(TelnetCommand.BREAK));
       str.flush();
    ..
    And even I test this
    Code:
    usr.write(new byte[]{(byte)TelnetCommand.IAC, (byte)TelnetCommand.BREAK});
     usr.flush();

  4. #4
    Join Date
    Dec 2009
    Posts
    204

    Re: Break a telnet connection

    Hello,
    By-cons, If I use the method println in class PrintStream are not force us to the CR and LF bytes?
    Here is the code.
    Code:
    PrintStream prstr = new PrintStream(getOutputStream());
    
    prstr.System.out.println({ (byte) TelnetCommand.IAC, (byte) TelnetCommand.BREAK });
    prstr.flush();
    Do you have any idea about this.

  5. #5
    Join Date
    Nov 2009
    Posts
    333

    Re: Break a telnet connection

    Hello,
    Is it worth while to send the byte BREAK? Try not, his behavior seems a little suspect. In fact, sends a command, it finishes by CR LF (or use System.out.println) and looks. I think it will better. Finally, after a short discussion, the CR LF may be better than System.out.println (), because in my memory System.out.println () retrieves the standard way to the platform to go on line (with windows is CR LF with Linux: only LF and MacOS with: CR, although I may be wrong by inverting for Linux & MacOS). And a Telnet server application explicitly CR LF.

  6. #6
    Join Date
    Dec 2009
    Posts
    204

    Re: Break a telnet connection

    Hello,
    This is what I have done in my code till now. I guess, if some people are interested then they will solve this problem. The code is here
    Code:
    ...
        static Final byte[] cmdbr = { (byte) TelnetCommand.IAC, (byte) TelnetCommand.BREAK };
    ...
     
        Final void _sendBRK()
        throws IOException, IllegalArgumentException
        {
            otpt.write(cmdbr);
            otpt.flush();
        }

Similar Threads

  1. Replies: 2
    Last Post: 17-02-2012, 02:09 PM
  2. Replies: 5
    Last Post: 14-12-2011, 06:09 PM
  3. Linux bash script for telnet connection
    By Rubero in forum Software Development
    Replies: 5
    Last Post: 23-08-2010, 09:08 PM
  4. How to use Telnet
    By Knight Rider in forum Technology & Internet
    Replies: 3
    Last Post: 22-08-2009, 02:11 PM
  5. testing connection with telnet
    By RaeS in forum Windows Vista Mail
    Replies: 3
    Last Post: 28-04-2008, 11:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,964,969.38505 seconds with 17 queries