> For the complete documentation index, see [llms.txt](https://netick.gitbook.io/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://netick.gitbook.io/v1/remote-procedure-calls-rpcs.md).

# Remote Procedure Calls (RPCs)

RPCs are method calls on Network Behaviors that are replicated across the network. They can be used for events or to transfer data.

An important use of RPCs is to set up the game and send configuration messages. Use reliable RPCs for things like that.

An RPC example:

```csharp
[Rpc(source: RpcPeers.Everyone, target: RpcPeers.InputSource, isReliable: true, localInvoke: false)]
private void MyRpc(int arg1)
{
    // Code to be executed
}
```

You use the \[Rpc] attribute to mark a method as an RPC.

{% hint style="info" %}

1. RPCs are not called on restimulated ticks.
2. By default all RPCs are unreliable.
   {% endhint %}

**RPC method constraints:**

* Must have the return type of void.
* Must only include parameters that can be networked. Same ones as the properties

**\[Rpc] attribute parameters**

* Source: the peer/peers the RPC should be sent from
* Target: the peer/peers the RPC will be executed on
* isReliable: whether the RPC is sent reliably or unreliably
* localInvoke: whether to invoke the RPC locally or not

**Source and target can be any of the following:**

* Owner (the server)
* Input Source: the client which is providing inputs for this Network Object
* Proxies: everyone except the Owner and the Input Source
* Everyone: the server and every connected client

### Source Connection of RPCs <a href="#source-connection-of-rpcs" id="source-connection-of-rpcs"></a>

If you need to know which connection (a client, or the server) the current RPC is being executed from, you can use `Sandbox.RpcSource`

```csharp
[Rpc(source: RpcPeers.Everyone, target: RpcPeers.InputSource, isReliable: true, localInvoke: false)]
private void MyRpc(int arg1)
{
    var rpcSource = Sandbox.RpcSource;
}
```
