mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29:35 +08:00
Winsock support
This commit is contained in:
@@ -79,9 +79,10 @@ public:
|
||||
close();
|
||||
}
|
||||
|
||||
addr_.sin_family = AF_INET;
|
||||
addr_.sin_family = PF_INET;
|
||||
addr_.sin_port = htons(port);
|
||||
InetPton(AF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr);
|
||||
addr_.sin_addr.s_addr = INADDR_ANY;
|
||||
InetPton(PF_INET, TEXT(host.c_str()), &addr_.sin_addr.s_addr);
|
||||
|
||||
socket_ = socket(PF_INET, SOCK_DGRAM, 0);
|
||||
if (socket_ == INVALID_SOCKET)
|
||||
@@ -113,7 +114,8 @@ public:
|
||||
|
||||
void send(const char *data, size_t n_bytes)
|
||||
{
|
||||
if ((sendto(socket_, data, static_cast<int>(n_bytes), 0, (struct sockaddr *)&addr_, sizeof(struct sockaddr))) == -1)
|
||||
socklen_t tolen = sizeof(struct sockaddr);
|
||||
if (sendto(socket_, data, static_cast<int>(n_bytes), 0, (struct sockaddr *)&addr_, tolen) == -1)
|
||||
{
|
||||
throw_spdlog_ex("sendto(2) failed", errno);
|
||||
close();
|
||||
|
Reference in New Issue
Block a user