RunL() not getting hitted....
| Fri, 2006-04-28 11:38 | |
|
Hi,
i am testing my SocketManager dll using an exe. I am runing my application on two different emulators on two different PCs. Now what the Problem is: on one of the emulator i am creating udp socket which is waiting for data to read, RecvFrom() is issued in Asynchronous mode n after that i have started my CActiveScheduler's Start() loop,now it is continuously waiting for the RunL() of reader object to be hitted. on another emulator(which is running on another PC), i create a udp socket n then issue SendTo() call for sending data on the first emulator, now as soon as i issue SendTo() it gets successfull n emulator where i send the data gets closed, but irony is that its RunL() is not getting hitted(bcoz it is not issuing any logs in the log file). N also i have checked through ethereal that data is reaching its destination IP n the specified port... Could anybody suggest the reason behind it........ ![]() ![]() Regards, Amit. |
|







Forum posts: 982
pirosl
Forum posts: 41
How can it be possible that inspite of issuing RecvFrom() asynchronously, i start active scheduler's loop n emulator which have to receive data keeps on stucking in start()'s infinite loop n as soon as data arrives on the port where RecvFrom is issued, emulator gets closed.
i have also tried one thing that after issuing RecvFrom(), i have not started active scheduler's loop but even then as soon as i send data("Hi!How r u...??") from my source emulator to the destination emulator, it gets closed.
I am not being able to find it's reason...
bcoz even i can't set breakpoint anywhere to check where this illwill is hapening.....
Regards,
Amit.
Forum posts: 982
pirosl
Forum posts: 41
Forum posts: 98
Forum posts: 41
Forum posts: 982
pirosl
Forum posts: 41
here i give u snippets from my code:
*************************************************************
//socket reader header.
*************************************************************
class CUdpSocketReader:public CActive
{
private:
CSocket *aOurSocket;
//Will contain pointer to the socket which is containing this CUdpSocketReader object.
LogManager *iLogManager;
RSocket& iSocket;
//Will be initialised with iSocket object contained in CSocket base class
//which is containing this iSocket object.
HBufC8 *ReadBuffer;
//It will contain the received data.
TInetAddr anAddr;
//Will contain the address of remote host.
public:
static CUdpSocketReader* NewLC(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr);
static CUdpSocketReader* NewL(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr);
void ConstructL(TUint aReceivedDataBufferSize);
CUdpSocketReader(CSocket *aSocket,RSocket& aSocketRef,LogManager* aLogManagerPtr);
//Will allocate memory to the ReadBuffer pointer variable on Heap.
//How much memory to allocate will be passed as argument in NewL() or NewLC().
~CUdpSocketReader();
TInt ReadAsync(MHSSSocketMgrCallback* aEventListenerPtr=NULL);
//Will issue Read() function of RSocket object Asynchronously.
//Returns 1 for success n -1 for failure(if any).
TInt RecvFromAsync(MHSSSocketMgrCallback* aEventListenerPtr=NULL);
//Returns 1 for success n -1 for failure.
//Will issue RcvFrom() function of RSocket object Asynchronously.
void GetLengthOfDataRcvd(TUint& aLengthRef);
//Synchronous implementation.
//Length of Data will be returned in the aLengthRef through iLength variable.
void GetReadBufData(TDesC8& aBufferRef);
//Synchronous implementation.
//Data will be returned in the aBufferRef argument.
void GetUdpRcvdBuffer(TDes8& aBufferRef,TDes& aRemoteIpAddrRef,TUint& aRemotePortRef);
//will return Data, Remote IP n Port in the arguments of above function.
void RunL();
//From CActive.
void DoCancel();
//From CActive.
};
//end of header file.
*****************************************************************
CUdpSocketReader* CUdpSocketReader::NewLC(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr)
{
CUdpSocketReader* self = new (ELeave) CUdpSocketReader(aSocket,aSocketRef,aLogManagerPtr);
CleanupStack::PushL(self);
self->ConstructL(aReceivedDataBufferSize);
return self;
}
CUdpSocketReader* CUdpSocketReader::NewL(CSocket *aSocket,RSocket& aSocketRef,TUint aReceivedDataBufferSize,LogManager* aLogManagerPtr)
{
CUdpSocketReader* self = CUdpSocketReader::NewLC(aSocket,aSocketRef,aReceivedDataBufferSize,aLogManagerPtr);
CleanupStack::Pop();
return self;
}
void CUdpSocketReader::ConstructL(TUint aReceivedDataBufferSize)
{
ReadBuffer = HBufC8::NewL(aReceivedDataBufferSize);
CActiveScheduler::Add( this );
}
CUdpSocketReader::CUdpSocketReader(CSocket *aSocket,RSocket& aSocketRef,LogManager* aLogManagerPtr)
:CActive( EPriorityStandard ),
aOurSocket(aSocket),
iSocket(aSocketRef),
iLogManager(aLogManagerPtr)
{
}
void CUdpSocketReader::RunL()
{
     iLogManager->LmPrint(Debug,_L("%s"),_S(RunL hitted));
if(iStatus == KErrNone)
aOurSocket->CallbackToSocket(EHSSDataReceived,iStatus.Int());
else
aOurSocket->CallbackToSocket(EHSSDataReceivingFailed,iStatus.Int());
}
TInt CUdpSocketReader::RecvFromAsync(MHSSSocketMgrCallback* aEventListenerPtr)
{
if(IsActive())
return -1;
iSocket.RecvFrom(ReadBuffer->Des(),anAddr,0,iStatus);
//iStatus variable is from CActive class.
SetActive();//From CActive.
return 1;
}
After this point control returns back to the statement in my exe which is:
CActiveScheduler::Start();
n after it program is in waiting state, i am assuming that it is in AS's start loop n waiting for RunL() of RecvFrom() to be hitted.
But as soon as data arrives on this port where socket has issued RecvFrom(), emulator gets closed, RunL() does not get hit.
Forum posts: 982
pirosl
Forum posts: 41
I am just issuing RacvFrom() on some UDP socket.
Forum posts: 51
B
Forum posts: 41
B
Can u suggest any reason behind it...that why it is so....that as soon as data reaches on the port, enulator gets closed irrespective of whether i have started AS or not...
Amit.
Forum posts: 3
In my case, I create a UDP server socket which calls RecvFrom() from a separate thread and one UDP client socket to send data to a test SIP server running on different location on ethernet. Through ethereal I have checked that the data is sent and received successfully in my machine but server socket's RunL() is never called.
In fact the server socket thread stops responding when data reaches on my machine.
While creating sockets, I am successfully able to do RConnection.Start() with ethernet profile. For server socket Bind is also successful.
Please help if anyone knows the solution.