Hi All
I'm just getting started with UDP and have hacked Donation's UDPExample into the code you see here. Unfortunately both the calls to "bind" and "sendto" fail with UDPSOCKET_MEM errors
EthernetNetIf eth;
UDPSocket cfgSocket;
void onUDPSocketEvent(UDPSocketEvent e)
{
if ( e == UDPSOCKET_READABLE )
{
char buf[64] = {0};
Host host;
while( int len = cfgSocket.recvfrom( buf, 63, &host ) )
{
if( len <= 0 )
break;
pc.printf("From %d.%d.%d.%d: %s\n", host.getIp()[0], host.getIp()[1], host.getIp()[2], host.getIp()[3], buf);
}
}
}
int main()
{
pc.baud(115200);
pc.printf ("HEllo World - 7 *\n");
EthernetErr ethErr = eth.setup();
if( ethErr == ETH_OK )
{
IpAddr ip = eth.getIp();
pc.printf("mbed IP Address is %d.%d.%d.%d\r\n", ip[0], ip[1], ip[2], ip[3]);
}
else pc.printf ("ETHERNETSETUP FAILED\n");
cfgSocket.setOnEvent(&onUDPSocketEvent);
UDPSocketErr udpErr = cfgSocket.bind( Host(IpAddr(),5555) );
if ( udpErr != UDPSOCKET_OK )
ShowError(udpErr);
int i = 0;
Host brdHost(IpAddr(255,255,255,255), 5555); //broadcast test msg
char cfgRqstMsg[]="SERVER CONFIG REQUEST";
Timer tmr;
tmr.start();
while(1)
{
Net::poll();
if( tmr.read() > 5)
{
tmr.reset();
int nSent = cfgSocket.sendto(cfgRqstMsg,strlen(cfgRqstMsg),&brdHost);
pc.printf("PLONKER %d :: %d\n",++i,nSent);
if ( nSent < 0 )
ShowError((UDPSocketErr)nSent);
}
}
}
can anybody see why ??
thanks
dave
Hi All
I'm just getting started with UDP and have hacked Donation's UDPExample into the code you see here. Unfortunately both the calls to "bind" and "sendto" fail with UDPSOCKET_MEM errors
thanks
dave