package test;
import com.grt192.networking.GRTClientSocket;
import com.grt192.networking.SocketEvent;
import com.grt192.networking.SocketListener;
public class NetworkingTest {
static String host = "127.0.0.1";
static int port = 80;
public static void main(String[] args) {
System.out.println("Starting Network Test");
GRTClientSocket connection = new GRTClientSocket(host, port);
connection.addSocketListener(new SocketListener() {
public void dataRecieved(SocketEvent e) {
System.out.println("< " + e.getData());
}
public void onConnect(SocketEvent e) {
System.out.println("Connected!");
}
public void onDisconnect(SocketEvent e) {
System.out.println("Disconnected!");
}
});
connection.connect();
connection.start();
try {
connection.sendData("GET /index.html HTTP/1.0\n");
Thread.sleep(4000);
connection.disconnect();
System.exit(0);
} catch (Exception e) {
e.printStackTrace();
}
}
}