Click here to Skip to main content
Click here to Skip to main content

Voice chat using a client-server architecture

, 2 Aug 2003
Rate this:
Please Sign up or sign in to vote.
Voice chat networking
<!-- Add the rest of your HTML here -->

Application Details

This software is based on the client - server architecture. Commmunication between the clients is established through the server. Initially server is started. Clients connects to the server host. Server sends the new client list to all the existing clients. The client can select destination user from the user combo box. The software also provides save and play (user can save the sound and play it later). Client also has volume control feature. When client application is started microphone select option (recording) is enabled and microphone mute option is checked (playing) automatically by the program (user doesn't have to worry about the external settings).

Technical Details

Display Class

The recording and playing threads are created in OnInitDialog() of the Display class.
//    Create and Start Recorder Thread
record = new RecordSound(this);
//Create and Start Player Thread
play = new PlaySound1(this);

Thread functions are based on the code by great person, Paul Cheffers (from codeguru site). I am grateful to him for making my dream project into reality. PreCreateHeader() of the Display class (from constructor) creates some buffers for playing wavedata. (This prevents creation of buffers during runtime...)

When the client presses the connect button OnConnect() of the Display class the client connects to the server and displays the userlist and start button. On pressing the start button recording and playing is started by sending message to recording and playing threads. (OnStart function)

record->PostThreadMessage(WM_RECORDSOUND_STARTRECORDING, 0, 0);
play->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING, 0, 0);
These messages will activate corresponding functions defined in the message maps of the respective thread classes.

On pressing the stop button recording and playing is stopped by in the same way as above (OnStop Function). It also contains other functions which will be activated on pressing the buttons and some functions are activated from other classes. (mysocket and RecordSound classes).

mysocket class

OnReceive: When data arrives at the client it will call the Display Class's receive function which plays the sound by sending a message to the PlaySound Thread.
play->PostThreadMessage(WM_PLAYSOUND_PLAYBLOCK, 0, (LPARAM) lpHdr);

Message Format

Total length : 2020 bytes
  • 15 : header (destination username or special status)
  • 5 : Length of actual data
  • 2000 : Reserved for actual data.

RecordSound Class

PreCreateHeader()function creates buffers for recording data. These are added using waveInPrepareHeader() and waveInAddBuffer() functions in OnStartRecording function. (Called when Start button is explained earlier..)

Playsound1 Class

Contains the functions for starting, playing and stopping wavedata. Buffers are created initially in the Display class itself.

Other classes

MicMute, MicPhone, Mixer are the special classes to add several extra features to Voice - Chat function. Some of the concepts are collected from various developers at the codeguru and codeproject sites. I am grateful to those developers....!!!

Running the Application

First start the server application (with port number xxx). Then start a minimum of 2 clients on any hosts (same or different). Mention server host address and port xxx with username xyz. Then click the connect button. The userlist will be displayed. Select the user and click the start button to start the chat...

Note: Any client can chat with any other client and hence a client can receive data from any number of clients. Performance depends upon the situation. Developers are free to use their own ideas.. (please let me know if you see some new mechanism..)

I am eagerly awaiting your doubts and suggestions at

I am grateful to codeguru and codeproject site for connecting developers....and helping to realise their dreams..!!!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
India India
Nagareshwar is a security enthusiastic person involved in reverse engineering, vulnerability research, coding security tools etc. He spend most of the time in uncovering the secrets of computer world.

He holds 'Bachelor of Engineering' degree from National Institute of Technology of Karnataka, India. He had professional experience of 2.5 years in Novell. At Novell he was working on various security products including 'Novell Secure Login' and CASA.

For more details visit his website

Comments and Discussions

Questionnoises on the line PinmemberPeter Eugene Coleman9-Jan-14 6:08 
GeneralMy vote of 5 Pinmembershaima'6-Oct-13 2:57 
Questiondelayed sound PinmemberMember 334484831-Mar-13 20:56 
Questioncode voice PinmemberMember 886496816-Jun-12 11:28 
GeneralMy vote of 4 Pinmemberdeexian10-Nov-10 6:15 
Generalmemory leaks and PtrList in Server is not stable to hold clients Pinmembercaptainc/c++24-Apr-08 2:23 
QuestionURGENT!!! how can I send wave file to the server? Pinmemberunique_136412-Oct-07 6:08 
QuestionHow can this be done in asp chat to use voice chat? Pinmemberdhrupodi27-Jul-07 9:14 
GeneralVoice Recording??!! PinmemberDexterND14-May-07 2:48 
GeneralThanks a lot! Pinmemberzaodt2-May-07 6:56 
Generalhey plz plz plz Pinmembertroog13-Apr-07 13:44 
Generalplz, neeed help PinmemberNona4ever5-Dec-06 8:36 
GeneralRe: plz, neeed help PinmemberNagareshwar6-Dec-06 6:19 
GeneralVoice Chat in Mobile Devices Pinmemberyktan5-Jul-06 18:42 
Generalerror Exosip setup.h Pinmembertranthanhthi7-May-06 18:32 
Generalgive me details Pinmembermohamadrbayati11-Aug-05 11:04 
GeneralHelping Gramma Pinmember___Inhuman__22-May-05 12:37 
GeneralFor any one PinsussAnonymous13-Aug-04 11:11 
Generalneed help Pinmembersaima11-Jun-04 5:48 
hi need help frm Nagareshwar regarding this article .can u tell ur email address so that i can contact u .
GeneralRe: need help Pinmemberwaseemaashu6-Jan-10 5:53 
Generalvoice and data on ip network Pinmemberfebad9-Jun-04 14:20 
QuestionCan connect to 2 PCs on LAN??? Pinmemberwenfoo17-May-04 19:24 
AnswerRe: Can connect to 2 PCs on LAN??? Pinmembernagareshwar18-May-04 4:51 
GeneralRe: Can connect to 2 PCs on LAN??? Pinmemberwenfoo19-May-04 19:55 
Generalsilence supression PinmemberCooKieMatrix8-Mar-04 15:33 
GeneralRe: silence supression PinmemberNagareshwar8-Mar-04 22:54 
GeneralRe: silence supression PinmemberCooKieMatrix15-Mar-04 14:37 
QuestionHow to get a edit ctrl in html's content. Pinmembergoodboyws7-Mar-04 17:26 
QuestionMulti thread???? Pinmembertrecs334-Mar-04 23:08 
AnswerRe: Multi thread???? PinmemberNagareshwar5-Mar-04 0:33 
Generalcompile errors Pinmemberemilioarp1-Mar-04 10:24 
GeneralRe: compile errors PinmemberNagareshwar2-Mar-04 18:04 
GeneralRe: compile errors Pinmemberemilioarp3-Mar-04 4:22 
GeneralRe: compile errors PinmemberOrkblutt10-Mar-04 17:16 
GeneralRe: compile errors Pinsussvanvancela10-Jan-05 21:33 
GeneralRe: compile errors PinmemberAniruddha Das23-Dec-06 10:06 
QuestionRe: compile errors Pinmemberanil_mane10-Jan-07 7:40 
Generalhi Pinmembermike3mn27-Feb-04 18:19 
GeneralRe: hi PinmemberNagareshwar2-Mar-04 18:08 
GeneralRe: hi Pinmembermike3mn5-Mar-04 21:34 
GeneralRe: hi PinsussAnonymous12-Jun-04 12:34 
GeneralSend all is frequency, how to multicast PinsussAnonymous22-Feb-04 18:07 
GeneralRe: Send all is frequency, how to multicast PinmemberNagareshwar24-Feb-04 2:48 
GeneralExcellent Work Pinmemberkiranvj8-Jan-04 20:41 
GeneralRealease Build Error Plz Help PinmemberThe DevMan7-Jan-04 23:56 
GeneralRe: Realease Build Error Plz Help PinmemberNagareshwar8-Jan-04 18:24 
QuestionHow ?? PinsussAnonymous26-Dec-03 23:30 
GeneralI want to compress with this code PinsussDr.Bimboo4-Dec-03 15:41 
Generali need some guide on Voice chat in java using Java Media Framework Pinmembervehnu8-Nov-03 0:33 
GeneralRe: i need some guide on Voice chat in java using Java Media Framework PinmemberNagareshwar10-Nov-03 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150414.1 | Last Updated 3 Aug 2003
Article Copyright 2003 by Nagareshwar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid