---
title: "Create a UDP Server"
---

> Documentation Index
> Fetch the complete documentation index at: https://openarkstudio.github.io/arknet/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a UDP Server

Configure a C++20 application using [Installation](/arknet/get-started/installation). Start the server before running the [matching client](/arknet/features/udp/client).

## Echo Server

The server replies through the session associated with the source endpoint.
Build this server and the [client](/arknet/features/udp/client) as separate executables with the `arknet::arknet` interface
target. Run the server first and the client in another terminal. Press Enter in
the server terminal to stop it.

```cpp
#include <iostream>
#include <string_view>

#include <arknet/udp/udp_server.hpp>

int main()
{
    arknet::udp_server server;
    server.bind_recv([](auto& session, std::string_view datagram)
    {
        session->async_send(datagram);
    });
    if (!server.start("127.0.0.1", 7000))
    {
        std::cerr << arknet::get_last_error().message() << '\n';
        return 1;
    }
    std::cout << "UDP listening on 127.0.0.1:7000\n";
    std::cin.get();
    server.stop();
}
```


[Configuration and advanced usage](/arknet/features/udp/configuration) · [Performance](/arknet/features/udp/performance)

Source: https://openarkstudio.github.io/arknet/features/udp/server/index.mdx
