Thu Jan 03, 2013 11:35 pm
Fri Jan 04, 2013 9:12 pm
http://irg.cs.ohiou.edu/ocp/bundling.html
http://www.codeforge.com/article/142062
import java.io.*;
import java.net.*;
public class ConnectToRouter {
public static void main(String args[]) {
try {
// start a connection
Socket clientSocket1 = new Socket("hostname", 23);
System.out.println("Client1: " + clientSocket1);
// User defined Method
getPage(clientSocket1);
} catch (UnknownHostException uhe) {
System.out.println("UnknownHostException: " + uhe);
} catch (IOException ioe) {
System.err.println("IOException: " + ioe);
}
}
public static void getPage(Socket socketObj) {
try {
// Acquire the input and output streams
DataOutputStream dataOutBound = new DataOutputStream(
socketObj.getOutputStream());
BufferedReader dataInBound = new BufferedReader(
new InputStreamReader(socketObj.getInputStream()));
dataOutBound.writeBytes("login");
dataOutBound.writeBytes("\n");
// waits until its is the time to enter
try { Thread.sleep(5000); } catch (InterruptedException ie) { }
dataOutBound.writeBytes("password");
// wait for response...
String responseLine;
while ((responseLine = dataInBound.readLine()) != null) {
// Display each line to the console
System.out.println(responseLine);
}
// Clean up
dataOutBound.close();
dataInBound.close();
socketObj.close();
} catch (IOException ioe) {
System.out.println("IOException: " + ioe);
}
}
}
Tue Jan 08, 2013 9:06 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.