Skip to content
Logo

connect

Connects to an existing remote Cartesi machine server at the specified address. Returns a RemoteCartesiMachine instance that can be used to interact with the remote server. This is the main entry point for connecting to a running remote machine server from your application.

Function Signature

connect(address: string, timeout?: number): RemoteCartesiMachine
  • address: The address (host:port) of the remote machine server to connect to.
  • timeout (optional): Maximum time in milliseconds to wait for the remote server to connect before giving up and returning an error. Use -1 for no timeout.

Example

import {  } from "@cartesi/machine";
 
// Connect to an existing remote machine server on localhost:5000
const  = ("127.0.0.1:5000");
 
// You can now use remoteMachine as a RemoteCartesiMachine
const  = .();
.("Remote server version:", );
 
// When done, you can shutdown or disconnect as needed
.();