Package com.tailf.ned
Class TelnetSession
Object
com.tailf.ned.TelnetSession
- All Implemented Interfaces:
CliSession
A telnet transport.
Example:
TelnetSession c = new TelnetSession("127.0.0.1", 23);
-
Constructor Summary
ConstructorsConstructorDescriptionTelnetSession(NedWorker worker) Constructor for Telnet session object.TelnetSession(NedWorker worker, int readTimeout, NedTracer tracer, NedConnectionBase conn) Constructor with an extra argument for a readTimeout timer.TelnetSession(NedWorker worker, NedTracer tracer, NedConnectionBase conn) Constructor for Telnet session object.TelnetSession(NedWorker worker, String username, int readTimeout, NedTracer tracer, NedConnectionBase conn) Constructor with extra user name argument. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Read from socket until Pattern is encountered.Read from socket until Pattern is encountered.Read from socket until Pattern is encountered.Read from socket until Pattern is encountered.voidflush()Signals that the final chunk of data has be printed to the output transport stream.Needed by users that need to monitor a socket for EOF .voidPrints text to the output stream.voidPrint text to the output stream.booleanready()Tell whether this transport is ready to be read.booleanready(int timeout) booleangiven a live session, check if the server side has closed it's end of the socket.voidsetScreenSize(int width, int length) voidvoid
-
Constructor Details
-
TelnetSession
Constructor for Telnet session object. This method creates a a new telnet session on top of an existing connection. Telnet objects implement the Transport interface and they are passed into the constructor of the NetconfSession class.- Parameters:
worker- current NedWorker object- Throws:
IOException
-
TelnetSession
Constructor for Telnet session object. This method creates a a new telnet connection.- Parameters:
worker- current NedWorker objecttracer- Ned tracerconn- NedConnection object- Throws:
IOException
-
TelnetSession
public TelnetSession(NedWorker worker, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException Constructor with an extra argument for a readTimeout timer.- Parameters:
worker- current NedWorker objectreadTimeout- timeout in millisecondstracer- Ned tracerconn- NedConnection object- Throws:
IOException
-
TelnetSession
public TelnetSession(NedWorker worker, String username, int readTimeout, NedTracer tracer, NedConnectionBase conn) throws IOException Constructor with extra user name argument.- Parameters:
worker- current NedWorker objectusername-readTimeout- timeout in millisecondstracer- Ned tracerconn- NedConnection object- Throws:
IOException
-
-
Method Details
-
setScreenSize
- Throws:
IOException
-
expect
Read from socket until Pattern is encountered.- Specified by:
expectin interfaceCliSession- Parameters:
str- is a regular expression pattern which is match against each line read.include- controls if the pattern should be include in the returned string or not.- Returns:
- the characters read.
- Throws:
IOException
-
expect
- Throws:
IOException
-
expect
- Throws:
IOException
-
expect
- Throws:
IOException
-
expect
Read from socket until Pattern is encountered.- Specified by:
expectin interfaceCliSession- Parameters:
str- is a regular expression pattern which is match against each line read.- Returns:
- the characters read.
- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
SSHSessionExceptionIOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
SSHSessionExceptionIOException
-
expect
Read from socket until Pattern is encountered.- Specified by:
expectin interfaceCliSession- Parameters:
str- is a regular expression pattern which is match against each line read.timeout- indicates the read timeout- Returns:
- the characters read.
- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
SSHSessionExceptionIOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
- Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
public NedExpectResult expect(Pattern[] p, NedWorker worker) throws SSHSessionException, IOException - Specified by:
expectin interfaceCliSession- Throws:
SSHSessionExceptionIOException
-
expect
public NedExpectResult expect(String[] str, boolean include, int timeout, NedWorker worker) throws IOException - Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, NedWorker worker) throws IOException - Specified by:
expectin interfaceCliSession- Throws:
IOException
-
expect
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, boolean full) throws IOException - Throws:
IOException
-
expect
public NedExpectResult expect(Pattern[] p, boolean include, int timeout, boolean full, NedWorker worker) throws IOException - Throws:
IOException
-
expect
Read from socket until Pattern is encountered.- Specified by:
expectin interfaceCliSession- Parameters:
str- is a regular expression pattern which is match against each line read.include- controls if the pattern should be include in the returned string or not.full- controls if the pattern should be matched against the entire line, or if a positive match is accepted whenever the pattern matches any substring on a line.- Returns:
- the characters read.
- Throws:
IOException
-
expect
public String expect(String str, boolean include, boolean full, int timeout, NedWorker worker) throws IOException - Specified by:
expectin interfaceCliSession- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceCliSession
-
write
- Throws:
IOException
-
print
Prints text to the output stream.- Specified by:
printin interfaceCliSession- Parameters:
s- Text to send to the stream.- Throws:
IOException
-
println
Print text to the output stream. A newline char is appended to end of the output stream.- Specified by:
printlnin interfaceCliSession- Parameters:
s- Text to send to the stream.- Throws:
IOException
-
flush
Signals that the final chunk of data has be printed to the output transport stream. This method furthermore flushes the transport output stream buffer.- Specified by:
flushin interfaceCliSession- Throws:
IOException
-
getSocket
Needed by users that need to monitor a socket for EOF . This will return the underlying socket object. -
ready
Tell whether this transport is ready to be read.- Returns:
- true if there is something to read, false otherwise. This function can typically be used to poll a socket and see there is data to be read. Note that this method does not detect that the socket is in half-closed state and in such case will return false after timeout.
- Throws:
IOException
-
ready
- Throws:
IOException
-
serverSideClosed
public boolean serverSideClosed()given a live session, check if the server side has closed it's end of the socket. Note that it does not detect that the socket in half-closed state.- Specified by:
serverSideClosedin interfaceCliSession
-
setTracer
- Specified by:
setTracerin interfaceCliSession
-