summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/CDDBConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/CDDBConnection.java')
-rw-r--r--NET/worlds/scape/CDDBConnection.java465
1 files changed, 465 insertions, 0 deletions
diff --git a/NET/worlds/scape/CDDBConnection.java b/NET/worlds/scape/CDDBConnection.java
new file mode 100644
index 0000000..9d4d055
--- /dev/null
+++ b/NET/worlds/scape/CDDBConnection.java
@@ -0,0 +1,465 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.network.DNSLookup;
+/* */ import java.io.DataInputStream;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.net.Socket;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class CDDBConnection
+/* */ {
+/* */ private Socket sock;
+/* */ private PrintStream sockOut;
+/* */ private DataInputStream sockIn;
+/* */ private boolean readOnly;
+/* */ private boolean debug;
+/* */
+/* */ public CDDBConnection(CDDBHost host, boolean debug)
+/* */ throws IOException
+/* */ {
+/* 404 */ this.debug = debug;
+/* 405 */ if (debug) {
+/* 406 */ System.out.println("Contacting host " + host);
+/* */ }
+/* 408 */ this.sock = new Socket(DNSLookup.lookup(host.getHost()), host.getPort());
+/* 409 */ CDDBLookup.markActivity();
+/* 410 */ this.sockOut = new PrintStream(this.sock.getOutputStream(), true);
+/* 411 */ this.sockIn = new DataInputStream(this.sock.getInputStream());
+/* 412 */ String msg = recv();
+/* 413 */ if (msg.startsWith("200 ")) {
+/* 414 */ this.readOnly = false;
+/* 415 */ } else if (msg.startsWith("201 ")) {
+/* 416 */ this.readOnly = true;
+/* */ } else {
+/* 418 */ throw new IOException("Can't connect to " + host + ": " + msg);
+/* */ }
+/* */ }
+/* */
+/* */ public String command(String command) throws IOException
+/* */ {
+/* 424 */ send(command);
+/* 425 */ return recv();
+/* */ }
+/* */
+/* */ public String readBody() throws IOException
+/* */ {
+/* 430 */ String str = recv();
+/* 431 */ return str.equals(".") ? null : str;
+/* */ }
+/* */
+/* */ public void close()
+/* */ {
+/* */ try {
+/* 437 */ send("quit");
+/* 438 */ recv();
+/* 439 */ this.sock.close();
+/* */ }
+/* */ catch (IOException localIOException) {}
+/* */ }
+/* */
+/* */ private void send(String msg) throws IOException {
+/* 445 */ if (this.debug)
+/* 446 */ System.out.println("--> " + msg);
+/* 447 */ this.sockOut.println(msg);
+/* 448 */ CDDBLookup.markActivity();
+/* */ }
+/* */
+/* */ private String recv() throws IOException
+/* */ {
+/* 453 */ String msg = this.sockIn.readLine();
+/* 454 */ CDDBLookup.markActivity();
+/* 455 */ if (this.debug)
+/* 456 */ System.out.println("<-- " + msg);
+/* 457 */ return msg;
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\CDDBConnection.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file