title: Why is irc sending "command uknown"?
body: <p>I am trying to write an irc bot in c++ and have taken care of connecting and setting my nickname as well as the identity, pings are functioning also. The only problem I'm having is joining a channel. The server keeps sending back "JOIN :unknown command" I believe the following lines are most relevant:</p>
  
  <pre><code>#define JOIN "JOIN #test\r\n"
  send(IrcSocket, JOIN, strlen(JOIN),0);
  </code></pre>
  
  <p>on the off chance that nothing can be solved from what I have included the entrie program which might be a bit of an eyesore.</p>
  
  <pre><code>#define WIN32_LEAN_AND_MEAN
  #include &lt;iostream&gt;
  #include &lt;windows.h&gt;
  #include &lt;winsock2.h&gt;
  #include &lt;ws2tcpip.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string&gt;
  #pragma comment(lib, "Ws2_32.lib")
  
  int main()
  {
      WSADATA wsaData;
      int iresult=WSAStartup(MAKEWORD(2,2),&amp;wsaData);
      if(iresult!=0)
      {
                    printf("WSAStartup Failed: %d \n", iresult);
                    return 1;
      }
      struct addrinfo *result=NULL, *ptr=NULL, hints;
      ZeroMemory(&amp;hints,sizeof(hints));
      hints.ai_family=AF_INET;
      hints.ai_socktype=SOCK_STREAM;
      hints.ai_protocol=IPPROTO_TCP;
      #define DEFAULT_PORT "6667"
      #define DEFAULT_IP "192.168.0.10"
      iresult = getaddrinfo(DEFAULT_IP,DEFAULT_PORT,&amp;hints,&amp;result);
      if(iresult!=0)
      {
                    printf("getaddrinfo failed: %d\n", iresult);
                    WSACleanup();
                    return 1;
      }
      SOCKET IrcSocket= INVALID_SOCKET;
      ptr=result;
      IrcSocket=socket(ptr-&gt;ai_family, ptr-&gt;ai_socktype,ptr-&gt;ai_protocol);
      if (IrcSocket == INVALID_SOCKET)
      {
         printf("Error at socket(): %d \n", WSAGetLastError());
         freeaddrinfo(result);
         WSACleanup();
         return 1;
      }
      iresult=connect(IrcSocket,ptr-&gt;ai_addr,ptr-&gt;ai_addrlen);
      if(iresult==SOCKET_ERROR)
      {
         closesocket(IrcSocket);
         IrcSocket=INVALID_SOCKET;
         freeaddrinfo(result);
      }
  
  
      if(IrcSocket == INVALID_SOCKET)
      {
         printf("Unable to connect to irc server!");
         WSACleanup();
         return 1;
      }
      std::cout&lt;&lt;("connection made\n");
      #define NICK "NICK bottester\r\n"
      #define IDENT "USER bottester 0 0 bottester\r\n"
      #define JOIN "JOIN #test\r\n"
      char stringbuffer[256];
  
      iresult=send(IrcSocket,NICK, strlen(NICK),0);
       if(iresult == SOCKET_ERROR)
      {
         printf("send failed: %d\n", WSAGetLastError());
         closesocket(IrcSocket);
         WSACleanup();
         std::cin.get();
         return 1;
      }
      iresult=send(IrcSocket, IDENT, strlen(IDENT),0);
      if(iresult == SOCKET_ERROR)
      {
         printf("send failed: %d\n", WSAGetLastError());
         closesocket(IrcSocket);
         WSACleanup();
         std::cin.get();
         return 1;
      }
      std::cout&lt;&lt;"entering ping loop\n";
      char pingnumber[128];
      char pinganswer[17]="PONG :";
      #define PRMSG "PRIVMSG test :TESTBOT IS HERE!\r\n"
      for(;;)
      {
             memset(stringbuffer,0,256);
             recv(IrcSocket,stringbuffer,sizeof(stringbuffer),0);
             for(int j=0;j&lt;strlen(stringbuffer);j++)
             {
                     std::cout&lt;&lt;j&lt;&lt;stringbuffer[j]&lt;&lt;"\n";
             if(stringbuffer[j]=='P' &amp;&amp; stringbuffer[j+1]=='I' &amp;&amp; stringbuffer[j+2]=='N' &amp;&amp; stringbuffer[j+3]=='G')
             {
             memset(pingnumber,0,10);
             std::memcpy(pingnumber, stringbuffer+j+6,10);
             std::memcpy(pinganswer+6,pingnumber,10);
             std::memcpy(pinganswer+16, "\r\n",strlen("\r\n"));
             send(IrcSocket,pinganswer,strlen(pinganswer),0);
             std::cout&lt;&lt; "PINGED&lt;"&lt;&lt;pingnumber&lt;&lt;"\n";
             iresult=send(IrcSocket, JOIN, strlen(JOIN),0);
             std::cout&lt;&lt; "JOINED\n";
             send(IrcSocket, PRMSG, strlen(PRMSG),0);
             }
             }
      }
  
  
  }
  </code></pre>