openMSX
Socket.hh
Go to the documentation of this file.
1 #ifndef SOCKET_HH
2 #define SOCKET_HH
3 
4 #include <string>
5 
6 #ifndef _WIN32
7 #include <sys/types.h>
8 #include <sys/socket.h>
9 #include <sys/un.h>
10 #include <netinet/in.h>
11 #include <fcntl.h>
12 #include <unistd.h>
13 #else
14 #include <winsock2.h>
15 #endif
16 
17 namespace openmsx {
18 
19 #ifndef _WIN32
20 constexpr int OPENMSX_INVALID_SOCKET = -1;
21 constexpr int SOCKET_ERROR = -1;
22 using SOCKET = int;
23 #else
24 // INVALID_SOCKET is #defined as (SOCKET)(~0)
25 // but that gives a old-style-cast warning
26 static const SOCKET OPENMSX_INVALID_SOCKET = static_cast<SOCKET>(~0);
27 #endif
28 
29 std::string sock_error();
30 void sock_startup();
31 void sock_cleanup();
32 void sock_close(SOCKET sd);
33 int sock_recv(SOCKET sd, char* buf, size_t count);
34 int sock_send(SOCKET sd, const char* buf, size_t count);
35 
36 } // namespace openmsx
37 
38 #endif
openmsx::sock_startup
void sock_startup()
Definition: Socket.cc:27
openmsx::SOCKET
int SOCKET
Definition: Socket.hh:22
openmsx::OPENMSX_INVALID_SOCKET
constexpr int OPENMSX_INVALID_SOCKET
Definition: Socket.hh:20
LZ4::count
ALWAYS_INLINE unsigned count(const uint8_t *pIn, const uint8_t *pMatch, const uint8_t *pInLimit)
Definition: lz4.cc:207
openmsx::sock_recv
int sock_recv(SOCKET sd, char *buf, size_t count)
Definition: Socket.cc:62
openmsx::sock_send
int sock_send(SOCKET sd, const char *buf, size_t count)
Definition: Socket.cc:85
openmsx::sock_cleanup
void sock_cleanup()
Definition: Socket.cc:42
openmsx::SOCKET_ERROR
constexpr int SOCKET_ERROR
Definition: Socket.hh:21
openmsx::sock_close
void sock_close(SOCKET sd)
Definition: Socket.cc:52
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::sock_error
std::string sock_error()
Definition: Socket.cc:9