- if (!MOTD.size())
- {
- WriteServ(user->fd,"422 %s :Message of the day file is missing.",user->nick);
- return;
- }
- WriteServ(user->fd,"375 %s :- %s message of the day",user->nick,ServerName);
- for (int i = 0; i != MOTD.size(); i++)
- {
- WriteServ(user->fd,"372 %s :- %s",user->nick,MOTD[i].c_str());
- }
- WriteServ(user->fd,"376 %s :End of %s message of the day.",user->nick,ServerName);
+ std::string WholeMOTD = "";
+ if (!MOTD.size())
+ {
+ WriteServ(user->fd,"422 %s :Message of the day file is missing.",user->nick);
+ return;
+ }
+ WholeMOTD = std::string(":") + std::string(ServerName) + std::string(" 375 ") + std::string(user->nick) + std::string(" :- ") + std::string(ServerName) + " message of the day\r\n";
+ for (int i = 0; i != MOTD.size(); i++)
+ {
+ WholeMOTD = WholeMOTD + std::string(":") + std::string(ServerName) + std::string(" 372 ") + std::string(user->nick) + std::string(" :- ") + MOTD[i] + std::string("\r\n");
+ }
+ WholeMOTD = WholeMOTD + std::string(":") + std::string(ServerName) + std::string(" 376 ") + std::string(user->nick) + std::string(" :End of message of the day.\r\n");
+ // only one write operation
+ send(user->fd,WholeMOTD.c_str(),WholeMOTD.length(),NULL);
+