Click here to Skip to main content
11,930,048 members (48,726 online)
Click here to Skip to main content
Add your own
alternative version


69 bookmarked

Voice conference using Multicasting Technique

, 31 Jul 2003
Rate this:
Please Sign up or sign in to vote.
Using multicasting to create a voice conference
<!-- Add the rest of your HTML here -->


This application uses multicasting technique for audio conference. Interested clients will join the multicast group address ( - On the LAN when any client sends the voice data to multicast address it will be delivered to all the clients joined to that group by the underlying network automatically. (Even the sending host also receive the copy if it has joined to that address and the application has to handle this situation). If the client only wants to send the data and doesn't want to receive the data then it does not have to join to that group.

On the Internet this feature is possible if routers support multicasting. Otherwise virtual multicasting has to be simulated using mtunneling.(refer details on MBONE-multicast BACKBONE).

The client can select a 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 don't have to worry about the external settings).

Technical Details

Display Class

When the client application started recording and playing threads 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 connects client to 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 thread. (OnStart function)

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

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

Before starting the application the client has to join multicast group using mulitcast group address and port.. this has been done in the CreateSocket(...) function.(called from the Display class).

To receive the messages the client has to join the multicast group. Steps are as follows.

  • Create receiver socket
    Create(gport,SOCK_DGRAM, FD_READ)
  • Allow other application to use the port (gport).
    SetSockOpt(SO_REUSEADDR, (void *) &bMultipleApps, sizeof(BOOL), 
  • Join to the multicast group
    ip_mreq mreq;
    mreq.imr_multiaddr.s_addr = inet_addr(gaddr);    //group address
    mreq.imr_interface.s_addr = htons(INADDR_ANY);
    setsockopt(m_hSocket,IPPROTO_IP, IP_ADD_MEMBERSHIP, (char FAR *) &mreq,

To send the data the steps are as follows:

  • Create Sending socket
    SOCKADDR_IN hgroup;    
    CAsyncSocket send;
    memset(&hgroup, 0, sizeof(hgroup));
    hgroup.sin_family = AF_INET;
    hgroup.sin_addr.s_addr = inet_addr(gaddr);
    hgroup.sin_port = htons((USHORT)gport);
    send.Create(0, SOCK_DGRAM, 0);  
  • Set TTL value ...important
    ttl=8; //some value > 1    
    send.SetSockOpt(IP_MULTICAST_TTL, &ttl, sizeof(int), IPPROTO_IP)
  • Set loopback option to false to prevent loopback (optional)
    //depends upon underlying protocol..
    //application has to handle loopback(prefered...)    

RecordSound Class

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

Playsound1 Class

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

Other classes

MicMute, MicPhone, Mixer are 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

  • LAN : To start the application run the client program and specify the multicast group address ( ... and port (Specify even number 1024) and type username .Then press the Connect button to connect to the group. If successfully connected to the group the start button will be displayed. On clicking the start button recording will be started. Playing will be started automatically when new data arrives.
  • On the Internet a virtual environment has to be provided using mtunneling (since most routers don't support multicasting..)

Note Any client can send data at any time. Performance depends upon the situation. Developers are free to use their own ideas to improve (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 sites 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

You may also be interested in...

Comments and Discussions

Questionunable to run e application Pin
Member 1146146821-Feb-15 18:32
memberMember 1146146821-Feb-15 18:32 
GeneralHello Pin
Bindu Manohar10-Jan-08 8:02
memberBindu Manohar10-Jan-08 8:02 
Generalproblem during run the the program Pin
captainc/c++18-Nov-07 18:57
membercaptainc/c++18-Nov-07 18:57 
GeneralRe: problem during run the the program Pin
Nagareshwar18-Nov-07 19:24
memberNagareshwar18-Nov-07 19:24 
GeneralError when run program Pin
tuongnd8012-Apr-07 22:46
membertuongnd8012-Apr-07 22:46 
GeneralRe: Error when run program Pin
Nagareshwar13-Apr-07 7:42
memberNagareshwar13-Apr-07 7:42 
Generalwave Mixing Pin
sanjayrvyas3-Feb-06 2:59
membersanjayrvyas3-Feb-06 2:59 
Questionhow to use save Pin
divyajanet12-Dec-05 1:40
memberdivyajanet12-Dec-05 1:40 
Generalplease help me Pin
Kutti Ra30-Sep-05 17:18
memberKutti Ra30-Sep-05 17:18 
QuestionWhy +20 and leaving the first 20 chars? Pin
MPVBRao26-Dec-03 2:55
memberMPVBRao26-Dec-03 2:55 
Questionhow to start Pin
charukala15-Oct-03 15:47
membercharukala15-Oct-03 15:47 
AnswerRe: how to start Pin
dharani31-Oct-03 19:23
memberdharani31-Oct-03 19:23 
QuestionHow to support a microphone in C#? Pin
CNWORM22-Aug-03 21:12
memberCNWORM22-Aug-03 21:12 
GeneralIF,,,,, i think it is very good solution in the lan Pin
winart6-Aug-03 22:33
memberwinart6-Aug-03 22:33 
GeneralBandwidth Needed Pin
AntonDel1-Aug-03 9:57
memberAntonDel1-Aug-03 9:57 
GeneralRe: Bandwidth Needed Pin
nsry(Nagareshwar)1-Aug-03 20:42
sussnsry(Nagareshwar)1-Aug-03 20:42 
GeneralRe: Bandwidth Needed Pin
eslea2-Aug-03 22:32
membereslea2-Aug-03 22:32 
GeneralRe: Bandwidth Needed Pin
nsry3-Aug-03 21:01
membernsry3-Aug-03 21:01 
GeneralRe: Bandwidth Needed Pin
AntonDel4-Aug-03 6:28
memberAntonDel4-Aug-03 6:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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.151126.1 | Last Updated 1 Aug 2003
Article Copyright 2003 by Nagareshwar
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid