Thread: forgot how to do somthing...

  1. #1
    ackman
    Guest

    Unhappy forgot how to do somthing...

    ok, heres my lil dilema, im making an IRC client with wonsock, so far, so good, except i need to return a pong everytime a server sends a ping with a random number... I.E.

    server sends << PING 123321
    then i send >> PONG 123321

    this will enable me to stay connected to the server, now what my problem is, is i forgot how to replace variables. and my C++ book i use as a referance is sorta missing in action, i think i let a friend use it anyways.

    right after my
    recv(Socket, data, 1024, 0);

    i have a strcmp looking for ping, now when it recieves the ping i simply want to change ping to pong set it to a string and send it back.
    send(Socket, data, 1024, 0);

    thus giving me my automated ping pong event handler... but i forgot how to change ping to pong =/ also, to prevent abuse, how would i make it only send pongs back to the server, because with strcmp some jack ass in a room could just type ping blah a bunch and make me send false pongs to the server most likely getting my client Z:lined for flooding.

    thanks in advance.

  2. #2
    ackman
    Guest

    ..

    anyone?

    i remember doin somthin similar like this a long time ago, i think i used strcmp and strcat, but im not sure...

  3. #3
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    Try this.
    Code:
       if ((strncmp(data,"PING",4)) == 0)
          data[1] = 'O';
       else
          cout << "PING not found." << endl;

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You could also use strstr, which returns a pointer to the phrase 'PING', assuming that's what you're looking for, then modify the next character up from the returned pointer.

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. New programmer missing somthing -- help!
    By jimmy the saint in forum C Programming
    Replies: 20
    Last Post: 02-23-2008, 05:57 PM
  2. Forgot how to use base class properly
    By gustavosserra in forum C++ Programming
    Replies: 3
    Last Post: 04-23-2004, 06:02 AM
  3. MSDN and somthing else
    By Granger9 in forum C Programming
    Replies: 1
    Last Post: 09-05-2002, 01:56 PM
  4. Forgot the attachment!
    By SyntaxBubble in forum Windows Programming
    Replies: 3
    Last Post: 04-26-2002, 03:50 PM
  5. Sorry, forgot to log in when I posted this message....
    By face_master in forum C++ Programming
    Replies: 2
    Last Post: 08-27-2001, 09:13 AM