| Reply | « Previous Thread | Next Thread » |
|
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);
}
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;
}
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
Why this is happening ??????? |
|
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 |
|
But RecvOneOrMore function waits forever until data has not received. Is there any need to send a dumy message to keep connection alive
|
|
Hi,
Best way you make a call to receive it and read it in your RunL() and issue another receive request. -Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |