- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
is possible to send packets in uClinux like broadcast ? I include code: ---------------------------- void udp_init_all(void) { // proved nastaveni ciloveho adresata soketoveho spojeni host = gethostbyname("192.168.3.255"); // remote server if(host==NULL) { printf("Address error."); return; } // nastav struktury a cilovy port adresata remoteServAddr.sin_family = host->h_addrtype; memcpy((char *) &remoteServAddr.sin_addr.s_addr, host->h_addr_list[0], host->h_length); // remoteServAddr.sin_port = htons(serverPort); // navaz sitove spojeni if ((socketDescriptor = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { printf("Not able to create socket connection. \n"); return; // exit(1); } serverAddress.sin_family = AF_INET; serverAddress.sin_addr.s_addr = inet_addr(SRC_IP_ADR); //"192.168.3.238"); } -------------------------- and sending code in main cycle: -------------------------- // nastav adresu portu a posli udp paket remoteServAddr.sin_port = htons(serverPort); if (sendto(socketDescriptor, out_buf, len, 0, (struct sockaddr *) &remoteServAddr, sizeof(remoteServAddr)) < 0) { printf("I am not able to send data to remote server.\n"); // close(socketDescriptor); return; // exit(1); } ----------------------------- and code report me: I am not able to send data to remote server. How can i send packets via broadcast ? Where is error ? Thank you for answer. Jan Naceradsky, Czech RepublicLink Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is sending IP packets as braoadcast not just using the broadcast address of the terwork you ar targeting (e.g. 192.168.2,255) ?
As routers don't forward broadcasts, I suppose not giving a network address will not work. -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, i use broadcast address (in my case 192.168.3.255).
I found, that ping -c 5 192.168.3.255 send data, but without answer - 5 packets transmitting, 0 received. May be i should use another function, not sendto(.....), in c source code. Jan- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't think that ping is bound to support broadcast.
A user protocol that does support broadcast is UDP. You need to write code for both ends. -Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When i use:
ping -c 5 192.168.3.255 the command tries to send 5 packets, every packets i can see in wireshark, but the uclinux doesnot get answer. You mean, that i must to write program for pc (except program for uClinux) ? (yes, i use the udp protocol) Jan- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes,
-Michael- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
--- Quote Start --- When i use: ping -c 5 192.168.3.255 the command tries to send 5 packets, every packets i can see in wireshark, but the uclinux doesnot get answer. --- Quote End --- I think that you hit the command 'ping -c 5 192.168.3.255' from your Nios uClinux system. If so, please consider who will reply the answer. Can your network reply to the 'ping broadcast' ? MS Windows OS ignores such broadcasts and Linux can ignore those by setting 'echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts'. Kazu
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page