Thread: programming a chat clientserver...

  1. #1
    Registered User
    Join Date
    Apr 2002

    programming a chat clientserver...

    I have written a chat program. But I am having touble with reading both the keybord and port at the same time. If I write cin>> the program is stuck here until something comes in if i don't write it, it is impossible to write anything on the console.

    I'm using Visual Studio 6.0 and are using winsock to comunicate between the client and server. If I use the client to listen to the keybord, and server to listen to the port everything works. but I cant get the client(or server) to do both.

    I tried to use threads but it I had some of the same trubble there. Is it possible to time out the cin>> at a spesific time if nothing is typed?

    How is it possible to solve this problem?

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Have you tried the cin.peek() function?

  3. #3
    Use kbhit(). It returns 1 when a key is hit.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Well if your working with windows I would recomend ::GetAsyncKeyState instead of kbhit. Although I am not sure thats really the way to solve this problem. I would lean towards using the keydown function in the message loop and "send" when ever a key was pressed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some help with my chat room code !!
    By beaditya in forum C Programming
    Replies: 2
    Last Post: 09-10-2005, 04:37 PM
  2. Requesting Java Chat Client Maintenence
    By ygfperson in forum A Brief History of
    Replies: 6
    Last Post: 04-02-2003, 01:57 PM
  3. Chat server/client trial -- anyone interested?
    By ygfperson in forum A Brief History of
    Replies: 3
    Last Post: 01-23-2003, 10:47 PM
  4. SO close to finishing chat program...!
    By Nakeerb in forum C++ Programming
    Replies: 13
    Last Post: 10-26-2002, 12:24 PM
  5. Rough Portable Chat Design Sketch
    By ggs in forum A Brief History of
    Replies: 0
    Last Post: 08-27-2001, 07:44 AM