Skip to content

Commit

Permalink
Being compatible with Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mayong authored and skeskinen committed Sep 1, 2023
1 parent 2d2f2aa commit 8c34cf4
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions examples/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,9 @@
#include <cstring>

#ifdef WIN32
#include <io.h>
#include <stdint.h>
#include <winsock2.h>
#include <Ws2ipdef.h>
#include "winsock2.h"
#include "include_win/unistd.h"
typedef int socklen_t;

#ifndef _SSIZE_T_DEFINED
#ifdef _WIN64
typedef unsigned __int64 ssize_t;
#else
typedef _W64 unsigned int ssize_t;
#endif
#define _SSIZE_T_DEFINED
#endif
#define read _read
#define close _close

Expand All @@ -33,6 +22,7 @@ typedef _W64 unsigned int ssize_t;
#endif



std::string receive_string(SOCKET_HANDLE socket) {
static char buffer[1 << 15] = {0};
ssize_t bytes_received = read(socket, buffer, sizeof(buffer));
Expand Down

0 comments on commit 8c34cf4

Please sign in to comment.