₦airaland Forum

Welcome, Guest: Register • Login • With Google • Trending • Recent • New

Stats: 3,344,801 members, 8,513,759 topics. Date: Thursday, 05 November 2026 at 01:11 PM

Toggle theme

Sesha's Posts

Nairaland Forum › Sesha's Profile › Sesha's Posts

1 (of 1 pages)

Programming › Re: Validate Telnet Connectivity by sesha(op): 10:54am On Mar 08, 2011
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.TimerTask;
import org.apache.commons.net.telnet.TelnetClient;
class Connectivity extends TimerTask
{
public static void main(String args[])
{
try
{
System.out.println("Please enter ip address"wink;
Scanner sc=new Scanner(System.in);
String ip=sc.nextLine().trim();
System.out.println("Please enter port number"wink;
TimerTask con  = new Connectivity();
Scanner sc1=new Scanner(System.in);
int port=sc1.nextInt();
Timer timer = new Timer();
    timer.scheduleAtFixedRate(con,1,1000);
Socket s1=new Socket(ip,port);
InputStream is=s1.getInputStream();
DataInputStream dis=new DataInputStream(is);
if(dis!=null)
{
System.out.println("Connected with ip "+ip+" and port "+port);
}
else
{
System.out.println("Connection invalid"wink;
}

dis.close();
s1.close();

}
catch(Exception e)
{
System.out.println("Not Connected,Please enter proper input"wink;

}

}

@Override
public void run() {
// TODO Auto-generated method stub

}
} grin
Programming › Validate Telnet Connectivity by sesha(op): 7:18am On Mar 02, 2011
Urgent-please help-how to validate telnet connectivity in my java code

1 (of 1 pages)