Server Help

Misc User Apps - Socket Problem

Versetti - Tue Jan 13, 2004 5:45 pm
Post subject: Socket Problem
Should this code below connect to the IRC server and go to the IRC channel #worldchat? because I tried and I don't see my program going in the channel when I'm in there I see no Dude w/e I named it entering.
Here is the code:
Code: Show/Hide
#include <iostream.h>
#include <winsock.h>
int main()


    {
    char myname[17] = " NICK Dude008\r\n";
    char myuserid[38] = "USER random \"S\" \"127.0.0.1\" :random\r\n";
    char mychan[18] = "JOIN #worldchat\r\n";
       cout << "A tiny IRC program\n";
       WSADATA WsaDat;
       if (WSAStartup(MAKEWORD(1,1), &WsaDat) != 0)


           {
           cout << "Error: Failed to start Winsock\n";
              return 0;
           }
           SOCKET mysocket;
           mysocket = socket(AF_INET, SOCK_STREAM, 0);
           SOCKADDR_IN SockAddr;
           SockAddr.sin_port = htons(6667);
        SockAddr.sin_family = AF_INET;
        SockAddr.sin_addr.S_un.S_un_b.s_b1 = 66;
        SockAddr.sin_addr.S_un.S_un_b.s_b2 = 252;
        SockAddr.sin_addr.S_un.S_un_b.s_b3 = 1;
        SockAddr.sin_addr.S_un.S_un_b.s_b4 = 55;
           if (connect(mysocket, (SOCKADDR *)(&SockAddr), sizeof(SockAddr)) == SOCKET_ERROR)


               {
                  cout << "Error: Socket could not connect\n";
                  return 0;
               }
               send(mysocket, myname, sizeof(myname), 0);
            cout << "Sent nick\n";
            Sleep(MAKEWORD(10,10));
            send(mysocket, myuserid, sizeof(myuserid), 0);
            cout << "Sent user id\n";
            Sleep(MAKEWORD(10,10));
            send(mysocket, mychan, sizeof(mychan), 0);
            cout << "Joining #WorldChat\n";
            Sleep(MAKEWORD(10,10));
            return 0;
        }


plz help this is what I'm stuck so far o yea and also too send a chat msg in irc I just use send(mysocket, msghere,sizeof(msghere),0);
and should it send something to the chat after I connect?
Versetti - Wed Jan 14, 2004 7:00 pm
Post subject:
hmmm guess no one knows how too then Grrrr this sucks now........
CypherJF - Thu Jan 15, 2004 3:58 pm
Post subject:
never learned c++ sockets :/
Versetti - Thu Jan 15, 2004 6:11 pm
Post subject:
NVM I got it too enter finally but just now getting the msg sorted out which that will be a pain!!!!
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group