> For the complete documentation index, see [llms.txt](https://docs.proudnet.com/proudnet/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.proudnet.com/proudnet/proudnet/using_pn/server_client/using_server.md).

# 서버 활용법

## 타이머 루프, RMI, 이벤트 처리하기

서버에서 매 시간마다 호출하지 않아도 되지만, 일정 시간마다 무언가를 수행하고자 한다면 서버를 시작할 때 <mark style="color:orange;">타이머 콜백 함수</mark>, <mark style="color:orange;">콜백 주기</mark>, <mark style="color:orange;">콜백 함수</mark>에 전달할 사용자 정의 데이터를 지정해야 합니다.

이들을 지정하는 곳은 다음과 같습니다.

<table data-full-width="false"><thead><tr><th width="81">언어</th><th width="198">타이머 콜백 함수</th><th width="250">콜백 주기</th><th>사용자 정의 데이터</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" %}
**참고**\
[**서버에서 수신 및 이벤트 콜백**](/proudnet/pn_reference_ko/notes/main_loop.md#undefined-2)\
[**서버에서 타이머 콜백**](/proudnet/pn_reference_ko/notes/main_loop.md#undefined-3)
{% endhint %}

## 여러가지 정보 가져오기

<mark style="color:orange;">Server</mark> 에서는 클라이언트 목록, P2P 그룹 정보, 클라이언트의 IP 정보, ping time 등 여러가지 정보를 가져올 수 있습니다.

<table data-full-width="false"><thead><tr><th width="217">C++ 함수</th><th width="215">C# 함수</th><th>설명</th></tr></thead><tbody><tr><td>Proud.CNetServer.GetClientCount</td><td>Nettention.Proud.NativeNetServer.GetClientCount</td><td>연결된 클라이언트의 수를 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetClientHostIDs</td><td>Nettention.Proud.NetServer.GetClientHostIDs</td><td>연결된 클라이언트의 HostID 목록을 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetClientInfo</td><td>Nettention.Proud.NetServer.GetClientInfo</td><td>매개변수로 주어진 HostID를 가진 클라이언트의 정보를 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetJoinedP2PGroups</td><td>-</td><td>매개변수로 주어진 HostID를 가진 클라이언트가 속해있는 모든 p2p 그룹을 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetLastUnreliablePingMs</td><td>Nettention.Proud.NetServer.GetLastUnreliablePingMs</td><td>가장 최근에 찍힌 ping time 을 milisecond 단위로 반환합니다.</td></tr><tr><td>Proud.CNetServer.GetP2PGroupInfo</td><td>Nettention.Proud.NetServer.GetP2PGroupInfo</td><td>매개변수로 주어진 p2p 그룹의 정보를 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetP2PGroups</td><td>-</td><td>모든 p2p 그룹을 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetRecentUnreliablePingMs</td><td>Nettention.Proud.NetServer.GetRecentUnreliablePingMs</td><td>가장 최근에 찍힌 ping time 을 milisecond 단위로 반환합니다.</td></tr><tr><td>Proud.CNetServer.GetRemoteIdentifiableLocalAddrs</td><td>-</td><td>클라이언트가 인식할 수 있는 서버의 listening port address를 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetStats</td><td>Nettention.Proud.NetServer.GetStats</td><td>서버 상태 정보를 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetTcpListenerLocalAddr</td><td>Nettention.Proud.NetServer.GetTcpListenerLocalAddr</td><td>Tcp 통신이 가능한 로컬 주소를 모두 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetTimeMs</td><td>Nettention.Proud.NetServer.GetTimeMs</td><td>현재 서버 시간을 ms 단위로 가져옵니다.</td></tr><tr><td>Proud.CNetServer.GetUdpListenerLocalAddrs</td><td>-</td><td>Udp 통신이 가능한 로컬 주소를 모두 가져옵니다.</td></tr><tr><td>Proud.CNetServer.IsConnectedClient</td><td>Nettention.Proud.NativeNetServer.IsConnectedClient</td><td>매개변수로 주어진 HostID를 가지고 있는 클라이언트가 연결된 상태인지를 반환합니다.</td></tr></tbody></table>

## 서버 간 통신하기

서버가 서로 역할 분담을 해서 작동할 경우, 각 서버 간 통신을 위해 서로의 연결을 구축할 필요가 있습니다. 이때 P2P 그룹을 활용하면 서버 간 통신을 용이하게 구성할 수 있습니다.

> * 1개의 <mark style="color:orange;">팜 서버(Farm server)</mark>를 둡니다. 서버 컴퓨터가 존재하는 LAN 그룹을 <mark style="color:orange;">서버 팜(server farm)</mark>이라 부릅니다.
> * 다른 모든 서버는 팜 서버에 접속하는 <mark style="color:orange;">팜 클라이언트(Farm Client)</mark>끼리 P2P 통신을 합니다.

각 팜 클라이언트, 즉 서버 프로세스끼리는 서버, 클라이언트 상관없이 서로 직접 통신을 주고 받을 수 있습니다. 무작위 형태의 그물망 통신이 가능하고 서로 간 자유로운 종속 관계를 구축할 수 있습니다.&#x20;

서버 간 통신을 위해 <mark style="color:orange;">net\_main</mark> 사용을 권장하며 통신의 <mark style="color:orange;">message\_length</mark> 도 고려되어야 합니다.

{% hint style="success" %}
**참고**

[**서버 팜 - 위키**](https://ko.wikipedia.org/wiki/%EC%84%9C%EB%B2%84_%ED%8C%9C)
{% endhint %}

***

## :arrow\_left: [뒤로](/proudnet/proudnet/using_pn/server_client.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
