Beispiel #1
0
void Server::sendMessage(NPT_UdpSocket* socket, std::string nt, std::string message)
{
    std::string msg = buildMsg(nt, message);

    NPT_IpAddress upnpAddress = getUPNPAddress();
    NPT_DataBuffer buffer;
    NPT_SocketAddress address;

    address.SetIpAddress(upnpAddress);
    address.SetPort(UPNP_PORT);

    buffer.SetData((NPT_Byte*)msg.c_str(), msg.length());
    socket->Send(buffer, &address);
}
Beispiel #2
0
void Server::sendReply(std::string host, int port, std::string msg)
{
    NPT_UdpSocket socket;
    NPT_DataBuffer buffer;

    NPT_IpAddress ip;
    NPT_SocketAddress address;

    ip.Parse(host.c_str());
    address.SetIpAddress(ip);
    address.SetPort(port);

    buffer.SetData((NPT_Byte*)msg.c_str(), msg.length());
    socket.Send(buffer, &address);
}