TCP communication
UDX uses negotiated TCP sockets. In typical two-process setups, one side acts as server (listens) and the other as client (connects).
Roles
| Function | Role |
|---|---|
start_server | Calls udx_init_tcp_client_negoc — creates the listening side |
connect_to_server | Calls udx_init_tcp_server_negoc — connects to an existing port |
The printed port from start_server must be passed to connect_to_server on the other process.
Example: big integer and MPFI interval
Terminal A (server):
using UDX
ch = UDX.start_server()
# Note the port from the printed message
UDX.udx_write_mpz(ch, BigInt(123))
UDX.udx_flush(ch)
using MPFI
a = UDX.udx_read_mpfi(ch)
println("Received interval: ", a)
println("Precision: ", precision(a))Terminal B (client):
using UDX
ch = UDX.connect_to_server(Int32(PORT)) # replace PORT
received_num = UDX.udx_read_mpz(ch)
println("Received number: ", received_num)
using MPFI
UDX.udx_write_mpfi(ch, BigInterval(1//3; precision=14))
UDX.udx_flush(ch)Load MPFI before using udx_read_mpfi / udx_write_mpfi so the MPFI extension is active.