You Are Here:

Community: Developer Discussion Boards

#1 Old Question RecvOneOrMore getting failed - 2009-01-15, 13:45

Join Date: May 2008
Posts: 39
Simron
Offline
Registered User
Hi,

My application is on Connection between PC and symbian mobile.
I have used RFCOMM protocol for connection. I have Active Objects in my code.
My problem is that after sending data, RecvOneOrMore function get failed, as there no data been send from PC to mobile. Only on request from PC the data is send and mobile receive it, till that if no data is send by PC the mobile application RecvOneOrMore should be in wait, which is not happening.

Following is the code of RunL()
Code:
void
CSymbSocket::RunL()
{
	TInt iMtuSize = 512;
	TBool boRet = EFalse;
	TInt iBytesReceived = 0;
	TBuf<MAX_LOG_SIZE> szErrMsg;
	TBuf<MAX_MSG_SIZE> szRecvBuf;
	TInt iRet = 0, iError = KErrNone;
	
	_LIT(KFUNCNAME, "CSymbSocket::RunL()");
	_LIT(KSTART, "START");
	_LIT(KEND, "END");
	
	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KSTART);

	if (m_iStatus != KErrNone)
	{
		_LIT(KDISCONNECTION, "RunL Disconnecting Now : ");
		
		szErrMsg.Zero();
		szErrMsg.Copy(KDISCONNECTION);;
		szErrMsg.AppendNum(m_iStatus.Int());
		WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, szErrMsg);
		
		//
		//	Stop Advertising
		//
		StopServerL(m_iStatus.Int());
		
		return;
	
	}

	switch (m_iState)
	{
		case EConnecting:
		{	
			_LIT(KConnect, "EConnecting");		
			WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KConnect);
			
			//
			//	Receive data from client
			//
			SocketReceiveL();
			break;
		}

		case EWaitingForMessage:
		{
			_LIT(KEWaitingForMessage, "EWaitingForMessage");		
			WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEWaitingForMessage);
			
			//
			//	Parse Request
			//
			boRet = ParseRequest(iError);
			if (EFalse == boRet)
			{
				_LIT(KFUNCTIONFAILED,"ParseRequest is Failed. Error: ");
				szErrMsg.Zero();
				szErrMsg.Append(KFUNCTIONFAILED);
				szErrMsg.AppendNum(iError);
				WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, szErrMsg);

				//
				//	Cleanup for  pcszXmlMsg
				//
				CleanupStack::PopAndDestroy();

				StopServerL(iError);
			}

			break;
		}


		case EDisconnected:
		{
			_LIT(KDISCONNECTION, "Disconnected");
			WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KDISCONNECTION);

			StopServerL(iError);
			break;
		}

	}
	
	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEND);
}
ParseRequest() function parse the receive data, take action on it and then return, while returning I have set m_iState = EConnecting and called SetActive();

Receive Code
Code:
TBool
CSymbSocket::SocketReceiveL(
	)
{
//	TSockXfrLength iReceiveLength = 0;

	_LIT(KEND, "End");
	_LIT(KSTART, "Start");
	_LIT(KFUNCNAME, "CSymbSocket::SocketReceiveL");
	
	#if DEBUG_CSYMBSOCKET_SOCKETRECEIVEL
	TBuf<MAX_LOG_SIZE> szLogMsg;
	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KSTART);
	#endif

	m_iState = EWaitingForMessage;
	
	//
	//	Receive message from client.
	//
	m_szXmlMessage.FillZ();
	m_szXmlMessage.Zero();
	m_AcceptedSocket.RecvOneOrMore(m_szXmlMessage,  0, m_iStatus, m_iReceiveLength);
	
	#if DEBUG_CSYMBSOCKET_SOCKETRECEIVEL
	_LIT(KRECV, "Receive Length = %d");
	szLogMsg.AppendFormat(KRECV, m_iReceiveLength);
	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, szLogMsg);
	#endif
			
	#if DEBUG_CSYMBSOCKET_SOCKETRECEIVEL
	WRITETOLOGEX(TRACE_LEVEL_INFO, KFUNCNAME, KEND);
	#endif

	SetActive();
	
	return ETrue;
}
Below is what i get at end of log
Code:
         .
         .
         .
         .
swrapcln.app CSymbSocket::ParseRequest() END
swrapcln.app CSymbSocket::RunL() END
swrapcln.app CSymbSocket::RunL() START
swrapcln.app CSymbSocket::RunL() EConnecting
swrapcln.app CSymbSocket::SocketReceiveL Start
swrapcln.app CSymbSocket::SocketReceiveL Receive Length = 805306372
swrapcln.app CSymbSocket::SocketReceiveL End
swrapcln.app CSymbSocket::RunL() END
swrapcln.app CSymbSocket::RunL() START
swrapcln.app CSymbSocket::RunL() RunL Disconnecting Now : -2147483647
swrapcln.app CSymbSocket::StopServerL Start
swrapcln.app CSymbBTServiceAdvertiser::StopAdvertisingL Start
swrapcln.app CSymbBTServiceAdvertiser::IsAdvertising Start
swrapcln.app CSymbBTServiceAdvertiser::IsAdvertising End
swrapcln.app CSymbBTServiceAdvertiser::StopAdvertisingL End
swrapcln.app CSymbSocket::StopServerL End
I receive data for the first time, but after that the application terminates.
Why this is happening ???????
Reply With Quote

#2 Old Re: RecvOneOrMore getting failed - 2009-01-16, 05:17

Join Date: Jun 2006
Posts: 1,043
Location: India
yogpan's Avatar
yogpan
Offline
Super Contributor
Hi,
Is it that if you are waiting for a very long time the socket connection is breaking. If that is the case that might be possible that instead of waiting indefinitely the API might be having some kind of timeout which is resulting in the connection breakage.I also encountered similar issue of disconnection but could not figure out how to prevent it. At last I just used to send some kind of health message to keep the connection alive to prevent timeout.


Maximus
S60 Developer
Impossible is nothing
Reply With Quote

#3 Old Re: RecvOneOrMore getting failed - 2009-01-19, 06:14

Join Date: May 2008
Posts: 39
Simron
Offline
Registered User
But RecvOneOrMore function waits forever until data has not received. Is there any need to send a dumy message to keep connection alive
Reply With Quote

#4 Old Re: RecvOneOrMore getting failed - 2009-01-27, 15:06

Join Date: Mar 2008
Posts: 577
mahbub_s60's Avatar
mahbub_s60
Offline
Forum Nokia Expert
Hi,

Best way you make a call to receive it and read it in your RunL() and issue another receive request.


-Mahbub
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
S60 5th ed emulator startup failed hony Symbian Tools & SDKs 8 2009-08-11 22:12
S60 5th Edition emulator startup problem gopitek General Symbian C++ 1 2009-01-13 17:51
emulator startup failed hony Symbian User Interface 3 2008-11-11 07:07
S60 2nd to 3rd/ PlatformSecurity / Capabilities jarkoos Installation, Certification and Security 4 2007-04-14 15:08
Nokia Image Converter davidpurdie General Discussion 0 2004-02-18 16:31

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia