连接到IRC服务器时出现问题
Issue connecting to IRC Server
最近一直在创建一个IRC机器人程序,虽然它似乎连接了&与大多数IRC服务器一起工作时,Twitch IRC服务器(IRC.Twitch.tv)似乎有问题
当连接到另一个服务器时,数据被接收&发送时没有任何问题,但是使用twitch连接,我无法发送或接收数据。
初始化:
Connection::Connection(char* server, int port, std::string nick, std::string pass)
{
fServer = server;
fPort = port;
fNick = nick;
fPass = pass;
fChanCount = 0;
clear_buffer();
fSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
cout << "Attempting to resolve host: " << fServer << endl;
fHost = resolve_host(fServer);
fSaddr.sin_addr.S_un.S_addr = fHost;
fSaddr.sin_port = htons(fPort);
fSaddr.sin_family = AF_INET;
cout << "Resolved to: " << fHost << endl;
}
开放连接:
int Connection::Connect()
{
if (connect(fSock, (sockaddr*)&fSaddr, sizeof(fSaddr)) == SOCKET_ERROR)
{
cout << "Can't connect to " << fServer << endl;
return 0;
}
recv(fSock, fBuffer, 1024 * 8, 0);
cout << fBuffer << endl << endl << flush;
send_message("PASS " + fPass);
send_message("NICK " + fNick);
send_message("USER " + fNick + " 0 * :" + fNick);
return 1;
}
清除缓冲区:
void Connection::clear_buffer()
{
memset(fBuffer, 0, sizeof(fBuffer));
}
接收:
string Connection::receive_message()
{
clear_buffer();
recv(fSock, fBuffer, 1024 * 8, 0);
return fBuffer;
}
完全弄不清楚是什么原因导致了这种情况,如果需要,可以提供更多细节。
您的USER消息看起来不像RFC2812规范所要求的那样。
3.1.3 User message
Command: USER
Parameters: <user> <mode> <unused> <realname>
The USER command is used at the beginning of connection to specify
the username, hostname and realname of a new user.
The <mode> parameter should be a numeric, and can be used to
automatically set user modes when registering with the server. This
parameter is a bitmask, with only 2 bits having any signification: if
the bit 2 is set, the user mode 'w' will be set and if the bit 3 is
set, the user mode 'i' will be set. (See Section 3.1.5 "User
Modes").
The <realname> may contain space characters.
Numeric Replies:
ERR_NEEDMOREPARAMS ERR_ALREADYREGISTRED
Example:
USER guest 0 * :Ronnie Reagan ; User registering themselves with a
username of "guest" and real name
"Ronnie Reagan".
USER guest 8 * :Ronnie Reagan ; User registering themselves with a
username of "guest" and real name
"Ronnie Reagan", and asking to be set
invisible.
也许这就是问题的原因?
否则,我发现一些服务器需要PASS
消息中的密码,即使服务器没有配置为需要密码。在这些情况下,我发送:
PASS none
相关文章:
- Java 客户端C++服务器数据发送/接收问题
- 使用 Libssh 将文件从服务器复制到客户端:分配文件复制目标路径时出现问题
- 从 tcp 服务器打开 8MP H264 流时出现问题
- C++中从客户端到服务器的数据传输问题
- UDP 客户端到 UDP 服务器的问题,出现 10057 错误
- C++机器人程序(我的私人服务器)出现问题
- Caffe 安装问题,远程服务器,ld 找不到 -<package>
- 服务器未收到UDP数据包,花费数小时试图找出问题所在
- C 多线程TCP服务器问题
- 套接字 TCP 服务器程序问题
- Linux TCP服务器问题C++
- 连接到IRC服务器时出现问题
- 服务器/客户端TCP异步(winsock)//FD_WRITE问题
- 基本服务器/客户端代码出现问题
- 通过套接字发送的图像流-服务器死锁问题
- 使用C++CGI解决服务器错误500时遇到问题
- C++:服务器上的 boost::文件系统问题(区域设置::facet::_S_create_c_locale 名称无效
- omniORB C++服务器,Java 客户机在运行应用程序时出现问题
- 提升 HTTP 服务器问题
- 问题4.8.4如何检查http服务器上是否存在文件