Puzzled (sockets and console)

This is a discussion on Puzzled (sockets and console) within the C++ Programming forums, part of the General Programming Boards category; Hey, at the moment, i've written a console program which currently connects to an IRC server and idles there. Here's ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Posts
    21

    Puzzled (sockets and console)

    Hey, at the moment, i've written a console program which currently connects to an IRC server and idles there. Here's the while loop i use:

    Code:
    while (1) {
       ::WSAWaitForMultipleEvents(1, &wsaevent,FALSE, INFINITE, FALSE);
       ::WSAEnumNetworkEvents(temp,wsaevent,&hProcessEvent); 
       if ((hProcessEvent.lNetworkEvents & FD_READ) &&  (hProcessEvent.iErrorCode[FD_READ_BIT] == 0)) {
       if (online) {
         // Connected to server and received data.. send it to the OnRecv() function
            OnRecv();
         } else {
            break;
         }
       }
    }
    and the OnRecv() function:

    Code:
    int IRCconnection::OnRecv() {
        //When incoming data detected.. do this
        string data;
        data = readline(); // Retreive line at a time
        checkreg(); // Check if registered
        checkforping(data); // See if the data received is from a ping request
    }
    Now at this same time, I would like for there to be an interface via this console program. ie an options menu....

    Code:
       1) Reload Database
       2) Change to next server
       3) Change Nickname
       etc...
    Now i was just wondering, if I created a display function, would the display be useable without disturbing the IRC connection. At any time it may respond to both console and IRC input.

    IRC via triggers, e.g. !slap and console via the menu. If you could provide any code to help me create a menu that wouldnt disturb IRC functions then that would be great.

    Thanks

  2. #2
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    I've never used WSAWaitForMultipleEvents, but my guess is that it's always waiting, especially since you're sending him a token like INFINITE.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making a virtual console (Linux)
    By Moddy in forum C++ Programming
    Replies: 2
    Last Post: 12-16-2005, 12:54 PM
  2. Redirecting console output to sockets
    By junbin in forum Windows Programming
    Replies: 1
    Last Post: 01-19-2003, 03:15 AM
  3. Beyond MFC : COM || Networking
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 04-25-2002, 05:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21