How do I tell Aeron which port to use?¶
Problem¶
You want an Aeron subscription to receive data on a particular UDP port.
Solution¶
Specify the host and port to listen on in the Aeron channel definition.
Discussion¶
Given a configured Aeron
object, you can define the listening host and port on a subscription calling the addSubscription
method with the desired channel configuration:
Subscription subscription
= aeron.addSubscription("aeron:udp?endpoint=192.168.0.1:12345", 1);
The example above has a channel configuration of aeron:udp?endpoint=192.168.0.1:12345
. This tells Aeron to construct a UDP channel, with the host set to 192.168.0.1
and port 12345
. Note you cannot bind subscriptions to remote hosts, and you cannot use ports already in use.