Forum Discussion
Altera_Forum
Honored Contributor
16 years agoHow to recieve UDP messages with SimpleSocketServer Example
Hello
I have a problem where I’d like to send a UDP broadcast message out to find any devices I have on my network and have those devices then respond with their IP addresses and some other config data. I have been trying to get the simplesocketsever example to accept a UDP message. All attempts thus far have failed. I can get it to accept TCP messages where I send messages to a specific IP. I have other hardware where I do the same thing and they respond. For example, I send out a broadcast message that contains a text string “hello” and the device responds back with all the data that it knows about itself. So I know that the message is being sent and that the concept works fine. I’m about ready to trash the Altera and go another route. Can anyone please help me by pointing out some documentation or examples of code that accept UDP streams. Thanks in advance………2 Replies
- Altera_Forum
Honored Contributor
Its more than just this tho...
TCP sockets use send/recv UDP sockets use sendto/recvfrom... - Altera_Forum
Honored Contributor
What you're really asking is a question about socket programming. Specifically, line 417 of "simple_socket_server.c" reads:
This is where the socket is actually created. To change the socket to UDP, change the line to read:if ((fd_listen = socket(AF_INET, SOCK_STREAM, 0)) < 0)
You should refer to the NicheStack reference material: http://www.altera.com/literature/ug/nichestackref.zip Jakeif ((fd_listen = socket(AF_INET, SOCK_DGRAM, 0)) < 0)