MCPcopy Create free account
hub / github.com/bwapi/bwapi / receivePacket

Method receivePacket

bwapi/SNP_DirectIP/SNP/UDPSocket.cpp:75–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75Util::MemoryFrame UDPSocket::receivePacket(UDPAddr &target, Util::MemoryFrame dest)
76{
77 //int targetSize = sizeof(target);
78 _state = 0;
79 int fromlen = sizeof(sockaddr);
80 int byteCount = ::recvfrom(_s, (char*)dest.begin(), dest.size(), NULL, (sockaddr*)&target, &fromlen);
81 if(byteCount == SOCKET_ERROR)
82 {
83 _state = WSAGetLastError();
84 if( _state == WSAEWOULDBLOCK
85 ||_state == WSAECONNRESET)
86 return Util::MemoryFrame();
87 throw GeneralException("::recv failed");
88 }
89 return dest.getSubFrame(0, byteCount);
90}
91
92int UDPSocket::getNextPacketSize()
93{

Callers 1

Calls 5

MemoryFrameClass · 0.85
GeneralExceptionClass · 0.85
beginMethod · 0.80
getSubFrameMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected