discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending UDP packets


From: Andreas Höschler
Subject: Re: Sending UDP packets
Date: Thu, 26 Nov 2009 10:57:06 +0100

Hi Saso,

Try replacing the "NSLog (@"sendto() failed");" with "perror ("sendto()
failed") - that will tell you exactly what went wrong. Also, as Lars
suggested, your application might be an ideal example of when to use IP
multicast (if you need, I can rewrite this code to work over multicast).

OK! I worked through the links Lars gave (Thanks Lars) and gathered the following information:
*******************************************************************************************************************
Broadcast: Sending data to all possible destinations (an "all-hosts broadcast") permits the sender to send the data only once, and all receivers can copy it. In the IP protocol, 255.255.255.255 represents a limited local broadcast. In addition, a directed (limited) broadcast can be made by combining the network prefix with a host suffix composed entirely of binary 1s. For example, to send to all addresses within a network with the prefix 192.0.2, the directed broadcast IP address is 192.0.2.255 (assuming the netmask is 255.255.255.0).

Multicast : A multicast address is associated with a group of interested receivers. According to RFC 3171 , addresses 224.0.0.0 to 239.255.255.255 are designated as multicast addresses. This range was formerly called "Class D." The sender sends a single datagram (from the sender's unicast address) to the multicast address, and the intermediary routers take care of making copies and sending them to all receivers that have registered their interest in data from that sender.

224.0.0.1 The All Hosts multicast group that contains all systems on the same network segment
*******************************************************************************************************************
It is not clear to me why multicast is to be preferred in my case. However, I also have no idea yet how to modify my code snippets to use multicast. By the way, my broadcast code works fine even with 192.168.1.255 as broadcast address on GNUstep/Solaris. However, it does not work

Sending packet 9
sendto() failed: Permission denied

on Cocoa/MacOSX! :-) And I need the code to work on both systems. For anyone interested to give it a try I have attached my test programs.

Attachment: UDPReceiver.tar.gz
Description: GNU Zip compressed data

Attachment: UDPSender.tar.gz
Description: GNU Zip compressed data



Thanks,

Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]