This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

UDP multicast message send error

Hi,

I cannot send UDP multicast message in ARM to 1900 port. It is SSDP.
netUDP_Send failed with unspecified error.

Any idea?

I will need full SSDP working in keil/ARM.

int32_t udp_sock;

udp_sock = netUDP_GetSocket (udp_cb_func);

netStatus net_status;

if (udp_sock > 0)
{ // Open UDP port 1000 for communication. net_status = netUDP_Open (udp_sock, 1900); // Let UDP Multicast datagrams cross a router. net_status = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2); NET_ADDR addr = { NET_ADDR_IP4, 1900, 255, 255, 255, 255 }; uint8_t *sendbuf;

const char* buf = "NOTIFY * HTTP/1.1\r\nHOST: 239.255.255.250:1900\r\nCACHE-CONTROL: max-age=100\r\n" "NT: upnp:rootdevice\r\nNTS: ssdp:alive\r\nSERVER: device/14.0.0, ProBuf, UPnP/1.1\r\nX-User-Agent: fkuehne-upnpx\r\n\r\n";

u32 size = strlen(buf);

sendbuf = netUDP_GetBuffer (size);
strncpy((char*)sendbuf, buf, size);

const uint8_t sgroup[NET_ADDR_IP4_LEN] = { 239,255,255,250 };
char ip_ascii[16];
if (netIGMP_Join (0, sgroup) == netOK) { netIP_ntoa (NET_ADDR_IP4, &sgroup[0], ip_ascii, sizeof(ip_ascii));
} else { return ES_NoError; }

net_status = netUDP_Send (udp_sock, &addr, sendbuf, size); }

Thanks,
Naeem

Parents
  • netUDP_Send is failing.

    netStatus s = netInitialize ();

    int32_t udp_sock;

    udp_sock = netUDP_GetSocket (udp_cb_func); if (udp_sock >= 0) { // Open UDP port 1000 for communication. s= netUDP_Open (udp_sock, 2000);

    // Let UDP Multicast datagrams cross a router. s = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2);

    // IPv4 address: 192.168.0.1 NET_ADDR4 addr = { NET_ADDR_IP4, 2000, 192, 168, 0, 1 }; uint8_t *sendbuf;

    sendbuf = netUDP_GetBuffer (2); sendbuf[0] = 0x01; sendbuf[1] = 0xAA;

    s = netUDP_Send (udp_sock, (NET_ADDR *)&addr, sendbuf, 2);

    // This UDP connection is no longer needed s = netUDP_Close (udp_sock); s = netUDP_ReleaseSocket (udp_sock);

    }

Reply
  • netUDP_Send is failing.

    netStatus s = netInitialize ();

    int32_t udp_sock;

    udp_sock = netUDP_GetSocket (udp_cb_func); if (udp_sock >= 0) { // Open UDP port 1000 for communication. s= netUDP_Open (udp_sock, 2000);

    // Let UDP Multicast datagrams cross a router. s = netUDP_SetOption (udp_sock, netUDP_OptionTTL, 2);

    // IPv4 address: 192.168.0.1 NET_ADDR4 addr = { NET_ADDR_IP4, 2000, 192, 168, 0, 1 }; uint8_t *sendbuf;

    sendbuf = netUDP_GetBuffer (2); sendbuf[0] = 0x01; sendbuf[1] = 0xAA;

    s = netUDP_Send (udp_sock, (NET_ADDR *)&addr, sendbuf, 2);

    // This UDP connection is no longer needed s = netUDP_Close (udp_sock); s = netUDP_ReleaseSocket (udp_sock);

    }

Children
No data