我无法通过Java与Chatango建立联系

时间:2015-09-17 14:41:08

标签: java

如果有人知道我为什么不能使用此代码连接chatango?这很奇怪,我确定服务器和端口是正确的。房间deinos.chatango.com

中没有任何内容
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;

public class Hello {
    public static void main(String[] args) throws Exception, IOException{
     //The Server
        String server = "s14.chatango.com";
        String str = "Hi,I am connecting to chatango using java :)\r\n\0";
        int port = 443;
     //The Socket Connection
     Socket sock = new Socket( server, port );

    InetAddress addr = sock.getInetAddress();
    //Print Connected
    System.out.println("Connected to " + addr);



    PrintWriter out =new PrintWriter(sock.getOutputStream(), true);
    BufferedReader in =  new BufferedReader(new           InputStreamReader(sock.getInputStream()));
    //Send Authorization to deinos
    out.println("bauth:deinos\0");
    //Print the String      
    out.println(str);

    //Closing all Connections        
        out.flush();
        in.close();
        out.close();
        sock.close();

    }
}

0 个答案:

没有答案