Skip to contents

Creates a nanonext publisher socket for broadcasting grid state updates to all worker processes.

Usage

create_pub_socket(port = 5555)

Arguments

port

Integer. TCP port for the publisher socket (default: 5555). Must be available and not blocked by firewall.

Value

A nanonext socket object configured for publishing.

Details

The publisher socket uses TCP on localhost to broadcast grid updates. Workers subscribe to this socket to receive notifications when pixels are added to the black set (walker termination events).

Communication pattern:

  • Main process publishes updates via this socket

  • Worker processes subscribe (see worker_init())

  • Non-blocking: workers poll for updates between steps

The socket binds to tcp://127.0.0.1:<port> and allows multiple subscribers to connect.

Examples

if (FALSE) { # \dontrun{
# Create publisher socket
pub_socket <- create_pub_socket(port = 5555)

# Broadcast an update
broadcast_update(pub_socket, position = c(10, 15), version = 42)

# Clean up
nanonext::close(pub_socket)
} # }