OXYGENHUB
◆ main openmsx / src / security / SocketStreamWrapper.cc
648 B · C++ · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
#ifdef _WIN32
2
3
#include "SocketStreamWrapper.hh"
4
#include "one_of.hh"
5
6
namespace openmsx {
7
8
using namespace sspiutils;
9
10
SocketStreamWrapper::SocketStreamWrapper(SOCKET userSock)
11
	: sock(userSock)
12
{
13
}
14
15
uint32_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
24
uint32_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