MCPcopy Create free account
hub / github.com/cuberite/cuberite / SendPacket

Method SendPacket

Tools/RCONClient/RCONClient.cpp:70–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70bool cRCONPacketizer::SendPacket(int a_PacketType, const AString & a_PacketPayload)
71{
72 // Send the packet:
73 cByteBuffer bb(a_PacketPayload.size() + 30);
74 bb.WriteLEInt(m_RequestID);
75 bb.WriteLEInt(a_PacketType);
76 bb.WriteBuf(a_PacketPayload.data(), a_PacketPayload.size());
77 bb.WriteBEShort(0); // Padding
78 AString Packet;
79 bb.ReadAll(Packet);
80 size_t Length = Packet.size();
81 if (!m_Socket.Send((const char *)&Length, 4))
82 {
83 fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.",
84 cSocket::GetLastError(), cSocket::GetLastErrorString().c_str()
85 );
86 return false;
87 }
88 if (!m_Socket.Send(Packet.data(), Packet.size()))
89 {
90 fprintf(stderr, "Network error while sending packet: %d (%s). Aborting.",
91 cSocket::GetLastError(), cSocket::GetLastErrorString().c_str()
92 );
93 return false;
94 }
95
96 return ReceiveResponse();
97}
98
99
100

Callers 1

RealMainFunction · 0.80

Calls 7

sizeMethod · 0.80
WriteLEIntMethod · 0.80
WriteBEShortMethod · 0.80
ReadAllMethod · 0.80
c_strMethod · 0.80
WriteBufMethod · 0.45
SendMethod · 0.45

Tested by

no test coverage detected