IRC: No Ident response
I am currently working on a IRC client written in Java.
As soon as the connection to the server is established I send these messages:
The first tests went pretty well - the server is responding. But every time it says:
I found a related question that helped a little bit. It says I need to listen on port 113 for a connection and a message to receive and respond to from the IRC-Server. I implemented a ServerSocket that listens on that port, but the server doesn't try to open a connection on port 113. What am I doing wrong?
Heres the code:
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()));
}
}
On execution I only get this displayed:
waiting for incoming socket
Do I need to send some other messages to avoid the ident check?
Have a look at this question for references to the underlying IRC protocol; it is somewhat more structured than the /
-commands you're used to seeing in a client. The handshake often looks something like this:
<< 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
where <<
indicates a line of text sent to the server and >>
indicates a line of text received from the server. Note also that IRC nominally uses rn
line endings, though a number of servers will accept n
too.
上一篇: IRC客户端C#PING请求
下一篇: IRC:无身份响应