This is multicasting based group chat application in which any number of users can join the group
and communicate together. It works on any network which will support multicasting. Multicasting is
supported by the wired LAN as well as wireless network. However multicasting is not supported by
What is multicasting?
Before getting into details of GroupTalk ,we have to be familiar with the term multicasting. Let us start with
unicasting and broadcasting. Unicasting is sending data to single host. Broadcasting
is sending data to all hosts on the network. Multicasting lies in between these two. It is sending data
to group of hosts. This group is identified by the multicast address.
Every host on the network has an IP Address. IP Address is divided into 5 classes. Each class
contains specific range of IP addresses.
Class A >> 0.0.0.0 - 220.127.116.11
Class B >> 18.104.22.168 - 22.214.171.124
Class C >> 192.0.0.0 - 126.96.36.199
Class D >> 188.8.131.52 - 184.108.40.206
Class E >> 240.0.0.0 - 255.255.255.255
Class D address is called multicast address. Each group on the network has unique multicast
address associated with it. In order to create the group you can choose any address in Class D. Its
safer to use any address starting from 220.127.116.11 to 18.104.22.168 since 224.*.*.* are generally
used for the router and group management.
Multicasting is quite different from unicasting /broadcasting. However it internally uses datagram socket for communication. Whenever one of the member sends any message to the group , then it will be automatically forwarded to all the members of that group. Important point to be noted here is that , you can send message to any group without joining the group. But in order to receive the messages from the group , you must have to join that group.
char strgroup[ ]="22.214.171.124";
mreq.imr_multiaddr.s_addr = inet_addr(strgroup);
mreq.imr_interface.s_addr = htons(INADDR_ANY);
setsockopt(m_hSocket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(char far *)&mreq,sizeof(mreq));
memset(&hgroup, 0, sizeof(hgroup));
hgroup.sin_family = AF_INET;
hgroup.sin_addr.s_addr = inet_addr(strgroup);
hgroup.sin_port = htons((USHORT)groupport);
send.Create(0, SOCK_DGRAM, 0);
ReceiveFrom (buffer, 2000, senderip, senderport);
setsockopt(m_hSocket, IPPROTO_IP, IP_DROP_MEMBERSHIP,
(char far *)&mreq , sizeof(mreq) ) ;
Since each multicast address represents a group. All hosts who wants to communicate together must use same group address. Sameway you can use different multicast address to create different group.
In order to implement group conference , you can use any simple ( your own!) protocol and suitable message format. I am using simple message format.
- Type : 5 bytes ( JOIN , LEAVE etc terminated with :)
- Username : Rest of the bytes
- General Message
- Type : 5 bytes ( MESG:)
- Username : 15 bytes (username terminated with 0)
- Length : 5 bytes
- Data : Rest of bytes....
As soon as member joins or leaves the group , JOIN or LEVE packet is sent to the group so that all the members can keep track of active members.
Running the application
In order to test multicasting based application , you must be on the multicast enabled network. Conventional LAN and wireless networks support multicasting. You cannot test this application on the single host. In order to test this application just run the grouptalk.exe file.
In addition to group conference application , it also demonstrates several useful concepts such as displaying icon in system tray ( similar to yahoo messenger) , building customized edit control for trapping ENTER key event , running application at start up through registry functions.
For any queries and suggestions , just drop me an email at