# 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.
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 )

UINT agk::CreateBroadcastListener( const char *szIP, UINT port )

integer CreateBroadcastListener( port )

UINT agk::CreateBroadcastListener( UINT port )

## Parameters

- szIP - The multicast IP to listen for, only applies to IPv6 networks, if left empty then it will listen for IPv4 broadcasts.
- port - The port that the messages are being broadcast on, in the case of AGK networks this will be port 45631.