OnReceive is not getting called??
Im trying somewhat simplest idea of sockets app using multicast.
Following is what *SockApp1* does:
1) _OnButtonCreate()_ creates the port, default OS assigned port.
Create(0, SOCK_DGRAM)
--------------------
m_pUDPSocket->Create(0, SOCK_DGRAM);
--------------------
2) When _OnButtonInitMulti()_ the mutlicast group(ip/port) is initialized.
Code:
--------------------
// set up destination address
memset(&m_addrMulti,0,sizeof(m_addrMulti));
m_addrMulti.sin_family =AF_INET;
m_addrMulti.sin_addr.s_addr =inet_addr(MULTIADDR);
m_addrMulti.sin_port =htons(MULTIPORT);
--------------------
3) When _OnButtonSend()_ it sends the data to the group.
Code:
--------------------
SendTo(m_sendBuffer, m_sendBuffer.GetLength(),
(const SOCKADDR* )&m_addrMulti, sizeof(m_addrMulti));
--------------------
*SockApp2* with following buttons clicked:
1) _OnButtonCreate()_ creates the port, default OS assigned port. Create(0,
SOCK_DGRAM)
Code:
--------------------
m_pUDPSocket->Create(0, SOCK_DGRAM);
--------------------
2) _OnButtonJoinMulti()_ joins the multicast group.
Code:
--------------------
ip_mreq mreq;
memset(&mreq, 0, sizeof(ip_mreq));
mreq.imr_multiaddr.s_addr = inet_addr(MULTIADDR);
mreq.imr_interface.s_addr = htonl(MULTIPORT);
if(SOCKET_ERROR == SetSockOpt(IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)))
{
AfxMessageBox("Error: Unable to add membership");
return -1;
}
--------------------
here
Code:
--------------------
#define MULTIADDR "224.0.1.129"
#define MULTIPORT319 5009
--------------------
Now, *SockApp1*, when i click onto the Send button, OnButtonSend() shud get
called in which im doing the SendTo() thing. Uptill here the App1/App2 both
are working fine, and the data is being sent successfully, this im sure.
The problem is, that *SockApp2*, which joined the group, is unable to
receive the data being sent from SockApp1.
Now, SockApp1 and SockApp2 are actually a _single_ app, called *SockApp*. I
added SockApp1/2 names just for the clarity of the question and
understanding.
At this moment, im just wondering... why SockApp2 is not receiving the data
from SockApp1???
Any ideas why?
--
synx
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------