载入中...
搜索中...
未找到
UdpSocket.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "NetTypes.h"
6
7#include <cstdint>
8#include <memory>
9#include <mutex>
10#include <string>
11#include <vector>
12
13namespace eve::data {
14class ByteData;
15}
16
17namespace Poco::Net {
18class DatagramSocket;
19}
20
21namespace eve::network {
22
23class Network;
24
27public:
29 explicit UdpSocket(Network* net);
31 ~UdpSocket();
32
34 bool bind(uint16_t port);
36 bool connect(std::string host, uint16_t port);
38 bool sendTo(eve::data::ByteData* data, std::string host, uint16_t port);
40 bool sendToString(std::string s, std::string host, uint16_t port);
42 bool send(eve::data::ByteData* data);
44 bool sendString(std::string s);
46 void close();
47
49 Poco::Net::DatagramSocket* datagram();
51 bool isBound() const { return bound_; }
53 Network* network() const { return net_; }
54
55private:
56 Network* net_ = nullptr;
57 std::unique_ptr<Poco::Net::DatagramSocket> sock_;
58 bool bound_ = false;
59 bool connected_ = false;
60};
61
62} // namespace eve::network
const std::string & s
#define EVENGINE_API_PLATFORM
Definition Export.h:107
UIHostHandle host
In-memory byte buffer implementing eve::Data (ref-counted).
Definition ByteData.h:13
Network module: TCP/UDP/HTTP factories, background worker, and completion event plumbing....
Definition Network.h:35
UDP socket backed by Poco::Net; supports connect/bind and datagram send.
Definition UdpSocket.h:26
Network * network() const
Owning module.
Definition UdpSocket.h:53
bool isBound() const
True after bind().
Definition UdpSocket.h:51