Skip to content

SocketImpl::available() #3834

@micheleselea

Description

@micheleselea

on NON LINUX platform with UDP socket I think we should check if result>0 before doing recvfrom otherwise calling the function with result=0 can have unpredictable behavior and give me error

int SocketImpl::available()
{
	int result = 0;
	ioctl(FIONREAD, result);
#if (POCO_OS != POCO_OS_LINUX)
	if (type() == SOCKET_TYPE_DATAGRAM)
	{
		std::vector<char> buf(result);
		result = recvfrom(sockfd(), &buf[0], result, MSG_PEEK, NULL, NULL);
	}
#endif
	return result;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions