hi ,
i have a simple
application which sends some data packet to a node and the node ,received
packet, send ack data.The application uses a pointer to the agent in
agent_.
i am able to send message to the node
using agent_->sendmsg(.....).
and the dest node also able rx the
packet.When i am trying to send the ack packet using(in the rx
side) agent_->sendmsg(....) it crashes .it is not able to use agent_
with rx side.
can any one tell me what could be the
problem.
I have defined a new agent from UDP
which sends my data.
i have attached the part
of the code .i am getting problem in the line colored Red.
In the receiver
node i could not access the "object pointer " agent_.
Simply accessing the agent_ variable it self make
segmentation fault.
please help me.
int simapp::command(int argc,const char*const* argv) { Tcl & tcl=Tcl::instance(); if(argc==2) { if(strcmp(argv[1],"start")==0) { start(); } } if(argc==3) { if(strcmp(argv[1],"attach-app")==0) { static int i=0; fprintf(stdout,"object count is %d",i); agent_=(Agent*)TclObject::lookup(argv[2]); fprintf(stdout,"agent address is %d \n",agent_); if(agent_==0) { tcl.resultf("no such a agent\n"); return (TCL_ERROR); } if(agent_->supportMM()) agent_->enableMM(); agent_->attachApp(this);
i++; return (TCL_OK); } } return(Application::command(argc,argv)); } void simapp::init()
{ } void
simapp::start()
{ init(); sendpkt(); } void simapp::stop()
{ } void simapp::sendpkt()
{ hdr_simapp *sim; agent_->sendmsg(6,"hello"); double next_time_=0.03; snd_timer_.resched(next_time_); } void simapp::recv_msg(int bytes,const char *msg
=0)
{ sendackpkt(); } void simapp::sendackpkt() { agent_->sendmsg(4,"hai"); } -----------------------------------------------------------------------------------------------
The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. -- George Bernard Shaw |