Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Forked from anonymous/Main.java
Created October 20, 2010 01:09
Show Gist options
  • Save DylanLukes/635564 to your computer and use it in GitHub Desktop.
Save DylanLukes/635564 to your computer and use it in GitHub Desktop.
package alphatunnel;
import java.io.IOException;
import java.io.FilterInputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.nio.CharBuffer;
import java.util.logging.Level;
import java.util.logging.Logger;
public class server extends Thread {
private static byte[] buffer;
public static FilterInputStream fromServer;
@Override
public void run() {
try {
buffer = new byte[4096];
Main.log("Connecting to the real server...");
Socket skt = new Socket("68.199.65.198", 6776);
Main.log("A connection has been established.");
fromServer = new FilterInputStream(skt.getInputStream());
while (skt.isConnected()) {
if (fromServer.available() > 0) {
fromServer.read(buffer);
Main.log("Server: " + buffer);
client.toClient.append(buffer);
}
}
} catch (UnknownHostException ex) {
Logger.getLogger(server.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(server.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment