MakeCallback with additional parameters

52 views
Skip to first unread message

Moab Rodrigues

unread,
Apr 14, 2015, 4:31:52 PM4/14/15
to ns-3-...@googlegroups.com
Hello everyone!
My problem already exist here in the forum, but nobody responded the question.


I want implement an extra argument in the method receive.

Example:

void ReceivePacket (Ptr<Socket> socket, Ptr<Socket> dest)
{
  while (socket->Recv ())
    {
      NS_LOG_UNCOND ("Node " << socket->GetNode()->GetId() << " received one packet!");
      dest->Send (Create<Packet>());
    }
    dest->Close();
}

//in the main function
Ptr<Socket> dest = Socket::CreateSocket ( ... );
intermediary->SetRecvCallback (MakeCallback(&ReceivePacket, dest));

The problem is than when I do this occurs errors.

Moab Rodrigues

unread,
Apr 14, 2015, 4:58:09 PM4/14/15
to ns-3-...@googlegroups.com
I solved with MakeBoundCallback.
Ex: MakeBoundCallback(&ReceivePacket, dest)
Reply all
Reply to author
Forward
0 new messages