setopt

setopt(sock::UDPSocket; multicast_loop = nothing, multicast_ttl=nothing, enable_broadcast=nothing, ttl=nothing)

Set UDP socket options. multicast_loop: loopback for multicast packets (default: true). multicast_ttl: TTL for multicast packets. enable_broadcast: flag must be set to true if socket will be used for broadcast messages, or else the UDP system will return an access error (default: false). ttl: Time-to-live of packets sent on the socket.

Examples

setopt(sock::UDPSocket;
        multicast_loop = true,
        multicast_ttl = nothing,
        enable_broadcast = false,
        ttl = nothing)

Set UDP socket options.

  • multicast_loop: Enable or disable loopback for multicast packets. The default value is true.
  • multicast_ttl: Set the TTL (Time-To-Live) value for multicast packets.
  • enable_broadcast: Set this flag to true if the socket will be used for broadcast messages. If not set, the UDP system may return an access error. The default value is false.
  • ttl: Set the Time-To-Live (TTL) value of packets sent on the socket.

Examples:

  1. Set multicast loopback to false:

    julia> s = UDPSocket();
    julia> setopt(s, multicast_loop = false);
  2. Set multicast TTL to 5:

    julia> s = UDPSocket();
    julia> setopt(s, multicast_ttl = 5);
  3. Enable broadcast messages on the socket:

    julia> s = UDPSocket();
    julia> setopt(s, enable_broadcast = true);
  4. Set TTL to 10 for packets sent on the socket:
    julia> s = UDPSocket();
    julia> setopt(s, ttl = 10);

Note: The examples assume that the UDPSocket object s has been properly initialized.

See Also

accept, bind, :@spawn, connect, fetch, getaddrinfo, gethostname, getipaddr, getsockname, init_worker, IPv4, IPv6, isready, issocket, kill, listen, recv, recvfrom, remotecall, remotecall_fetch, remotecall_wait, RemoteRef, send, setopt,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field
Details

Checking you are not a robot: