No reply on JOIN

I am writing a IRC client in C++ (with the help of the SFML library), but it is behaving strangely. I send the NICK and USER commands and I can connect to the server, but the JOIN command has many strange thing happening that I have to write "Random code that magically works" to solve. I am pretty sure that the commands adhere to the IRC RFC as well.

I know that the sockets are sending what they are supposed to send and I have verified it with Wireshark, so what I post here is what the message of the packet is. In the following examples the socket is already connected to the IRC server (which in this case is irc.freenode.net)

This works:

char mess[] ="NICK lmno nrUSER lmno 0 * :lmnonrJOIN #mytestnr";
Socket.Send(mess, sizeof(mess));

This does not:

char msg[] = "NICK lmno rnUSER lmno 0 * :lmno rn";
char msga[] = "JOIN #mytest rn";
Socket.Send(msg, sizeof(msg));
Socket.Send(msga, sizeof(msga));

But curiously this works:

char msg[] = "NICK lmno rnUSER lmno 0 * :lmno rn";
char msga[] = "JOIN #mytest rn";
Socket.Send(msg, sizeof(msg));
Socket.Send(msga, sizeof(msga));
Socket.Send(msga, sizeof(msga));

I did do some research on this topic and no one seems to have the same problem. Stranger is that when I tried this in telnet, I only have to send JOIN once. Is anyone able to give me some advice?

Thanks, SFI


It might have to do with the terminating '' character at the end of a c-string. Try

Socket.Send(msg, sizeof(msg) - 1);
Socket.Send(msga, sizeof(msga) - 1);
链接地址: http://www.djcxy.com/p/53458.html

上一篇: IRC“QUIT”无法正常工作

下一篇: JOIN没有回复