openMSX
SocketStreamWrapper.cc
Go to the documentation of this file.
1#ifdef _WIN32
2
4#include "one_of.hh"
5
6namespace openmsx {
7
8using namespace sspiutils;
9
10SocketStreamWrapper::SocketStreamWrapper(SOCKET userSock)
11 : sock(userSock)
12{
13}
14
15uint32_t SocketStreamWrapper::Read(void* buffer, uint32_t cb)
16{
17 int recvd = recv(sock, static_cast<char*>(buffer), cb, 0);
18 if (recvd == one_of(0, SOCKET_ERROR)) {
19 return STREAM_ERROR;
20 }
21 return recvd;
22}
23
24uint32_t SocketStreamWrapper::Write(void* buffer, uint32_t cb)
25{
26 int sent = send(sock, static_cast<char*>(buffer), cb, 0);
27 if (sent == one_of(0, SOCKET_ERROR)) {
28 return STREAM_ERROR;
29 }
30 return sent;
31}
32
33} // namespace openmsx
34
35#endif
This file implemented 3 utility functions:
Definition Autofire.cc:11
int SOCKET
Definition Socket.hh:25