UDP multicasting

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
gks
In need of some credit
In need of some credit
Posts: 3
Joined: Wed Feb 01, 2006 8:15 am
Contact:

UDP multicasting

Post by gks » Wed Apr 12, 2006 4:21 am

Target:Beginers.

This piece of code was tested :-)

Code: Select all


 //Tx  

       wxDatagramSocket  *sc1;

	wxIPV4address addr;
    wxIPV4address clientaddr;
    wxIPV4address mServerAddr;
    addr.AnyAddress();
    addr.Service(3000);
    clientaddr.Hostname("128.200.100.174");
    clientaddr.Service(3000);

	//mServerAddr.AnyAddress();
	mServerAddr.Hostname("128.200.255.255");

    mServerAddr.Service(3008);

	
	sc1 = new wxDatagramSocket(clientaddr, wxSOCKET_WAITALL);
	sc1->SendTo(mServerAddr, wxString("hi"), 2);



//Rx

wxDatagramSocket  *sc2;

	wxIPV4address addr;
    wxIPV4address clientaddr;
    wxIPV4address mServerAddr;
    addr.AnyAddress();
	//addr.Hostname("128.200.0.0");
    addr.Service(3008);
    clientaddr.Hostname("128.200.100.174");
    clientaddr.Service(3008);

	sc2 = new wxDatagramSocket(clientaddr, wxSOCKET_WAITALL);

       char buf[5];
	int len;
	
	wxString rxx;

    len = sc2->RecvFrom(addr,buf,2).LastCount();
	buf[len] = 0;
    rxx = buf;
	 wxMutexGuiEnter();
        Mains->SharedTextBox->AppendText(rxx.c_str());
        wxMutexGuiLeave();


[/code]
Forgive All :-)

Post Reply