# RemoteCartesiMachine

## Interface

This is the complete TypeScript interface of a remote `machine` object, which extends [CartesiMachine](/cm/api/cartesi-machine).
Descriptions for each method are in the following sections.

```ts
export interface RemoteCartesiMachine extends CartesiMachine {
    getServerAddress(): string;
    getServerPid(): number | null;
    shutdown(): void;
    rebind(address: string): string;
    emancipate(): void;
    setTimeout(ms: number): void;
    getTimeout(): number;
    setCleanupCall(call: CleanupCall): void;
    getCleanupCall(): CleanupCall;
    getServerVersion(): string;
    delayNextRequest(ms: number): void;
    getBoundAddress(): string | null;
    fork(): RemoteCartesiMachine;
    load(dir: string, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine;
    create(config: MachineConfig, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine;
    cloneEmpty(): RemoteCartesiMachine;
    store(dir: string): RemoteCartesiMachine;
}
```

## getServerAddress

Retrieves the address of the remote machine server.

```ts
getServerAddress(): string;
```

## getServerPid

Returns the server process ID if the server was spawned, or `null` if not available.

```ts
getServerPid(): number | null;
```

## shutdown

Shuts down the remote machine server. Does not delete the machine object.

```ts
shutdown(): void;
```

## rebind

Changes the address that the remote machine server is listening to and returns the actual bound address.

```ts
rebind(address: string): string;
```

## emancipate

Makes the server the leader of its own process group.

```ts
emancipate(): void;
```

## setTimeout

Sets a timeout (in milliseconds) for communication with the remote machine server.

```ts
setTimeout(ms: number): void;
```

## getTimeout

Gets the current timeout (in milliseconds) for communication with the remote machine server.

```ts
getTimeout(): number;
```

## setCleanupCall

Configures the implicit cleanup call to be performed when the object is deleted.

```ts
setCleanupCall(call: CleanupCall): void;
```

## getCleanupCall

Retrieves the implicit cleanup call that will be performed when the object is deleted.

```ts
getCleanupCall(): CleanupCall;
```

## getServerVersion

Gets the semantic version of the remote machine server.

```ts
getServerVersion(): string;
```

## delayNextRequest

Asks the server to delay the next request by the given number of milliseconds.

```ts
delayNextRequest(ms: number): void;
```

## getBoundAddress

Gets the address the server actually bound to (only available for spawned servers).

```ts
getBoundAddress(): string | null;
```

## fork

Forks the remote machine server, creating a new server process and machine object.

```ts
fork(): RemoteCartesiMachine;
```

## load

Loads a remote machine instance from a previously stored directory, with optional runtime configuration. Returns a `RemoteCartesiMachine` instance, allowing method chaining. Semantics are the same as for [CartesiMachine.load](/cm/api/cartesi-machine#load).

```ts
load(dir: string, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine
```

## create

Creates a new remote machine instance from the given configuration and optional runtime configuration. Returns a `RemoteCartesiMachine` instance, allowing method chaining. Semantics are the same as for [CartesiMachine.create](/cm/api/cartesi-machine#create).

```ts
create(config: MachineConfig, runtimeConfig?: MachineRuntimeConfig): RemoteCartesiMachine
```

## cloneEmpty

Clones an empty remote machine object from an existing one. Returns a `RemoteCartesiMachine` instance, allowing method chaining. Semantics are the same as for [CartesiMachine.cloneEmpty](/cm/api/cartesi-machine#cloneempty).

```ts
cloneEmpty(): RemoteCartesiMachine
```

## store

Stores the current remote machine instance to a directory, serializing its entire state. Returns a `RemoteCartesiMachine` instance, allowing method chaining. Semantics are the same as for [CartesiMachine.store](/cm/api/cartesi-machine#store).

```ts
store(dir: string): RemoteCartesiMachine
```
