IRC: No Ident response
我目前正在使用Java编写的IRC客户端。
一旦建立到服务器的连接,我就发送这些消息:
- /NICK test
- /JOIN #chat
号
第一个测试进行得很好-服务器正在响应。但每次它说:
- NOTICE AUTH :***
- Checking Ident
- NOTICE AUTH :***
- No Ident response
- ERROR :Closing Link ... (Registration timed out)
号
我发现了一个有帮助的相关问题。它说我需要在113端口上监听连接和从IRC服务器接收和响应的消息。我实现了一个在该端口上监听的serversocket,但服务器不尝试在端口113上打开连接。我做错什么了?
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.ServerSocket; import java.net.Socket; public class IdentProtocolThread extends Thread { private String nick; private ServerSocket serverSocket; private BufferedReader reader; private BufferedWriter writer; public IdentProtocolThread(String nick) throws IOException { this.nick = nick; this.serverSocket = new ServerSocket(113); } @Override public void run() { try { System.out.println("waiting for incoming socket"); Socket socket = this.serverSocket.accept(); System.out.println("socket accepted"); this.initialize(socket); System.out.println("reader/writer initialized"); String line = null; while ((line = this.reader.readLine()) != null) { System.out.println(line); } } catch (IOException e) { e.printStackTrace(); } System.out.println("done"); } private void initialize(Socket socket) throws IOException { this.reader = new BufferedReader(new InputStreamReader(socket.getInputStream())); this.writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); } } |
执行时,我只显示以下内容:
waiting for incoming socket
号
我是否需要发送其他消息以避免身份检查?
请看一下这个问题,以获取对底层IRC协议的引用;它的结构比您在客户机中看到的
1 2 3 4 5 6 7 8 9 10 | << USER foo . . :real name << NICK bar >> :server PING somethinglonghere << PONG :somethinglonghere >> :server 001 bar :Welcome! << JOIN #channel >> :bar!foo@yourhost JOIN #channel >> :server 332 bar #channel :channel topic >> :server 353 bar = #channel :@someop +somevoice someuser anotheruser >> :server 366 bar #channel :End of /NAMES list |
其中,
行结尾,尽管许多服务器也会接受