I'm having troubles to get that broadcast thingie working. Actually I'm having troubles to get it even compiled!
So far I've this:
Code: Select all
m_serverAddr.Hostname(GROUP_DEFAULT) m_serverAddr.Service(INFO_PORT); m_sock = new wxDatagramSocket( m_serverAddr, wxSOCKET_NOWAIT ); // Then later // This doesn't work without the struct-word. struct ip_mreq mreg; m_sock->SetEventHandler(*this, idUDPSocket); m_sock->SetNotify(wxSOCKET_INPUT_FLAG); m_sock->Notify(true); memset(&mreq,0,sizeof(ip_mreq)); mreq.imr_multiaddr.s_addr = inet_addr(GROUP_DEFAULT); mreq.imr_interface.s_addr = htons(INADDR_ANY); m_sock->SetOption(IPPROTO_IP, IP_ADD_MEMBERSHIP, (char far *)&mreq,sizeof(mreq));
Errors are :
- `GROUP_DEFAULT' undeclared
- aggregate `ip_mreq mreg' has incomplete type and cannot be defined
- `IP_ADD_MEMBERSHIP' undeclared
Those are the worst ones. For example, I couldn't find GROUP_DEFAULT from wxwidgets includes or from mingw. All I want is to send broadcast messages!
One another thing. If/when I get that to work and I want to send message to specific IP can I just use SendTo and later if I want to send another broadcast, do I initialize socket again or can I just use Write to send broadcast?