Examples/KniPong/main.cpp
/**
 * Connect UDP socket to other IP:port pair derived from our args
 */
Connect UDP socket to other IP:port pair derived from our args
Connect UDP socket to other IP : port pair derived from our args
void connectUDPSocket(const LinuxSocket& sock, const KniPongArgs& args)
{
	struct sockaddr_in ingress;
	std::memset(&ingress, 0, sizeof(ingress));
	ingress.sin_family = AF_INET;
	ingress.sin_addr.s_addr = inet_addr(args.outIp.c_str());
	ingress.sin_port = pcpp::hostToNet16(args.kniPort);
	if (connect(sock, (struct sockaddr*)&ingress, sizeof(ingress)) == -1)
	{
		int old_errno = errno;
		close(sock);
		EXIT_WITH_ERROR("Could not connect socket" << std::endl << "Errno: " << std::strerror(old_errno));
	}
}
void connectUDPSocket ( const LinuxSocket & sock , const KniPongArgs & args ) { struct sockaddr_in ingress ; std :: memset ( & ingress , 0 , sizeof ( ingress ) ) ; ingress . sin_family = AF_INET ; ingress . sin_addr . s_addr = inet_addr ( args . outIp . c_str ( ) ) ; ingress . sin_port = pcpp :: hostToNet16 ( args . kniPort ) ; if ( connect ( sock , ( struct sockaddr * ) & ingress , sizeof ( ingress ) ) == -1 ) { int old_errno = errno ; close ( sock ) ; EXIT_WITH_ERROR ( " " << std :: endl << " " << std :: strerror ( old_errno ) ) ; } }
Connect UDP socket to other IP:port pair derived from our args
Connect UDP socket to other IP : port pair derived from our args