CreateBroadcastListener

Description

Broadcasts are special network communications as they do not use a destination address and are instead received by all devices on a network. Broadcast packets are not forwarded by routers so can only be used on the local area network, or more specifically the local subnet. This can be useful for discovering devices as one device can send a broadcast packet containing its IP address and another device can pick it up, read the IP and connect back to the first device to create a two-way connection.

Warning, if the device listening for broadcasts is an iOS device then it may not be able to receive broadcast packets without permission from Apple. As of writing receiving is still allowed but sending requires permission from Apple, this may change in future

AGK networks are broadcast in this manner on port 45631 and send a packet containing the name of a network that has been hosted by another AGK device. By using a broadcast listener you can pick these messages up, extract the network names and display them to the user for them to choose which network they want to connect to.

If the device is on an IPv6 network then these rules change slightly. CreateBroadcastListener must be called with a multicast address, which begins with ff, for example ff02::1 and the broadcast listener will only receive packets sent to this multicast address. If no address is specified then the broadcaster will only receive IPv4 broadcasts. If you pass the address "anyip6" then the broadcast listener will listen on the AGK multicast address "FF02::41:474B" which is used for named network discovery on port 45631.

Returns an ID you can use to interact with this broadcast listener.

Definition

integer CreateBroadcastListener( szIP, port )

integer CreateBroadcastListener( port )

Parameters