# Utilization of Server

## Handling Timer Loop, RMI, and Events

You don't have to call it every hour on the server, but if you want to do something every certain amount of time, you'll need to specify a <mark style="color:orange;">timer callback function</mark>, a <mark style="color:orange;">callback period</mark>, and custom data to pass to the <mark style="color:orange;">callback function</mark> when you start the server.

Below is where to specify them

<table data-full-width="false"><thead><tr><th width="99">Language</th><th width="233">Timer callback function</th><th width="183">Callback period</th><th>Custom data</th></tr></thead><tbody><tr><td>C++</td><td>Proud.INetServerEvent.OnTimerCallback</td><td>Proud.CStartServerParameter.m_timerCallbackInterval</td><td>Proud.CStartServerParameter.m_timerCallbackContext</td></tr><tr><td>C#</td><td>Nettention.Proud.NetServer.TickDelegate</td><td>Nettention.Proud.StartServerParameter.timerCallbackIntervalMs</td><td>-</td></tr></tbody></table>

{% hint style="success" %}
**Reference**\
[**Receive and event callback on the server**](/proudnet.eng/proudnet-note/notes/main_loop.md#receive-and-event-callbacks)\
[**Timer callback on the server**](/proudnet.eng/proudnet-note/notes/main_loop.md#timer-callback)
{% endhint %}

## Getting various information

<mark style="color:orange;">Server</mark> allows you to get the client list, P2P group information, client IP information, ping time, and more.

<table data-full-width="false"><thead><tr><th width="189">C++ Functions</th><th>C# Functions</th><th>Description</th></tr></thead><tbody><tr><td>Proud.CNetServer.GetClientCount</td><td>Nettention.Proud.NativeNetServer.GetClientCount</td><td>Gets the number of connected clients.</td></tr><tr><td>Proud.CNetServer.GetClientHostIDs</td><td>Nettention.Proud.NetServer.GetClientHostIDs</td><td>Get a list of HostIDs of connected clients.</td></tr><tr><td>Proud.CNetServer.GetClientInfo</td><td>Nettention.Proud.NetServer.GetClientInfo</td><td>Gets information about the client with the HostID given as a parameter.</td></tr><tr><td>Proud.CNetServer.GetJoinedP2PGroups</td><td>-</td><td>Gets all the p2p groups that the client with the HostID given as a parameter belongs to.</td></tr><tr><td>Proud.CNetServer.GetLastUnreliablePingMs</td><td>Nettention.Proud.NetServer.GetLastUnreliablePingMs</td><td>Returns the most recently taken ping time in milliseconds.</td></tr><tr><td>Proud.CNetServer.GetP2PGroupInfo</td><td>Nettention.Proud.NetServer.GetP2PGroupInfo</td><td>Gets the information for the P2P group given by the parameters.</td></tr><tr><td>Proud.CNetServer.GetP2PGroups</td><td>-</td><td>Get all P2P groups.</td></tr><tr><td>Proud.CNetServer.GetRecentUnreliablePingMs</td><td>Nettention.Proud.NetServer.GetRecentUnreliablePingMs</td><td>Returns the most recently taken ping time in milliseconds.</td></tr><tr><td>Proud.CNetServer.GetRemoteIdentifiableLocalAddrs</td><td>-</td><td>Get the server's listening port address that the client can recognise.</td></tr><tr><td>Proud.CNetServer.GetStats</td><td>Nettention.Proud.NetServer.GetStats</td><td>Gets server status information.</td></tr><tr><td>Proud.CNetServer.GetTcpListenerLocalAddr</td><td>Nettention.Proud.NetServer.GetTcpListenerLocalAddr</td><td>Gets all local addresses with which TCP communication is possible.</td></tr><tr><td>Proud.CNetServer.GetTimeMs</td><td>Nettention.Proud.NetServer.GetTimeMs</td><td>Get the current server time in ms.</td></tr><tr><td>Proud.CNetServer.GetUdpListenerLocalAddrs</td><td>-</td><td>Gets all local addresses that are Udp communicable.</td></tr><tr><td>Proud.CNetServer.IsConnectedClient</td><td>Nettention.Proud.NativeNetServer.IsConnectedClient</td><td>Returns whether the client with the HostID given as a parameter is connected.</td></tr></tbody></table>

## Communicating between servers

If the servers work in a role-sharing manner, they need to establish a connection to each other for communication between each server. At this point, P2P groups can be used to facilitate server-to-server communication.

> * Set one <mark style="color:orange;">Farm server</mark>. A LAN group where server computers exist is called a <mark style="color:orange;">server farm</mark>.
> * All other servers have P2P communication between <mark style="color:orange;">Farm Clients</mark> that connect to the farm server.

Each farm client, or server process, can communicate directly with each other regardless of whether it is a server or a client. Random forms of mesh communication are possible and free dependencies between them can be established.

The use of <mark style="color:orange;">net\_main</mark> is recommended for server-to-server communication, and the <mark style="color:orange;">message\_length</mark> of the communication should also be considered.

{% hint style="success" %}
**Reference**

[**Server Farm from Wiki**](https://ko.wikipedia.org/wiki/%EC%84%9C%EB%B2%84_%ED%8C%9C)
{% endhint %}

***

## :arrow\_left: [Back](/proudnet.eng/proudnet/using_pn/server_client.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.proudnet.com/proudnet.eng/proudnet/using_pn/server_client/using_server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
