UDP Broadcast
- From: "paul.slocum" <paul.slocum@xxxxxxxxx>
- Date: Thu, 17 Jul 2008 14:59:05 -0700 (PDT)
I cannot get UDP broadcast to work in vxWorks. I either get errors
from sendto() or I just don't receive anything. I've tried everything
I can think of, different broadcast addresses (all zeros/all ones).
If I change the address for this same code to send the UDP message
directly to my laptop, then it works fine. Thanks in advance for any
help.
----------------------------------------------------------------------
mRouteEntryAdd (0xC0A809FF, 0xC0A80901, 0xffffffff, 0, 0, 1 );
while(1)
{
s = create_udp_socket(LOCAL_PORT);
// init target address structure
target_host_address.sin_family=PF_INET;
target_host_address.sin_port=htons(REMOTE_PORT);
target_address_holder=(unsigned
char*)&target_host_address.sin_addr.s_addr;
target_address_holder[0]=192;
target_address_holder[1]=168;
target_address_holder[2]=9;
target_address_holder[3]=152;
char optval=1;
setsockopt (s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval));
strcpy( buffer, "3MDS SENSOR " );
// send it
bstatus=sendto(s, buffer, BUF_SIZE, 0,
(struct sockaddr*)&target_host_address, sizeof(struct sockaddr));
close(s);
// wait ~10 seconds
taskDelay( 20 );
broadcastCount++;
}
----------------------------------------------------------------------
-> ifShow
motscc (unit number 0):
Flags: (0x8063) UP BROADCAST MULTICAST ARP RUNNING
Type: ETHERNET_CSMACD
Internet address: 192.168.9.100
Broadcast address: 192.168.9.255
Netmask 0xffffff00 Subnetmask 0xffffff00
Ethernet address is 00:a0:1e:b0:09:51
Metric is 0
Maximum Transfer Unit size is 1500
30308 octets received
10274 octets sent
389 packets received
168 packets sent
375 non-unicast packets received
1 non-unicast packets sent
14 unicast packets received
167 unicast packets sent
0 input discards
0 input unknown protocols
0 input errors
0 output errors
0 collisions; 0 dropped
lo (unit number 0):
Flags: (0x8069) UP LOOPBACK MULTICAST ARP RUNNING
Type: SOFTWARE_LOOPBACK
Internet address: 127.0.0.1
Netmask 0xff000000 Subnetmask 0xff000000
Metric is 0
Maximum Transfer Unit size is 32768
0 packets received; 0 packets sent
0 multicast packets received
0 multicast packets sent
0 input errors; 0 output errors
0 collisions; 0 dropped
value = 29 = 0x1d
.
- Follow-Ups:
- Re: UDP Broadcast
- From: paul.slocum
- Re: UDP Broadcast
- Prev by Date: Re: network driver + replenishment
- Next by Date: Re: UDP Broadcast
- Previous by thread: network driver + replenishment
- Next by thread: Re: UDP Broadcast
- Index(es):