This commit is contained in:
azw 2023-04-24 07:59:36 +00:00
parent e24aab092d
commit afffb63a95

View File

@ -14,6 +14,7 @@ namespace a8
UdpSession::UdpSession()
{
max_packet_len_ = DEFAULT_MAX_PACKET_LEN;
SetMaxPacketLen(max_packet_len_);
}
UdpSession::~UdpSession()
@ -33,6 +34,10 @@ namespace a8
void UdpSession::SetMaxPacketLen(int max_packet_len)
{
max_packet_len_ = std::max(max_packet_len, DEFAULT_MAX_PACKET_LEN);
if (!recv_buff_) {
recv_buff_ = (char *)malloc(max_packet_len_ + 1);
}
recv_bufflen_ = 0;
}
void UdpSession::OnSocketRead(char* buf, unsigned int buflen)