| Reply | « Previous Thread | Next Thread » |
|
Hi,
I 've been trying to open an L2CAP socket on the N3650 mobile in order to exchange some data with a linux PC via bluetooth. The code snippet I use is shown below: -------------------------------------------------------------------------------- TRequestStatus socketStatus, timerStatus; socket->Accept(*blank, socketStatus); SetSecurity(false, false, false, 5); RTimer timer; timer.CreateLocal(); timer.After(timerStatus, timeout); User::WaitForRequest(timerStatus, socketStatus); timer.Cancel(); timer.Close(); //Check the socket status if(socketStatus == KErrNone) return 1; else socket->CancelAccept(); -------------------------------------------------------------------------------- There are 2 cases here: either the timer expires and the accept operation is aborted or a connection is made within the specified timeout. The problem is that in both (!) cases a E32USER-CBase 46 exception is thrown. In the first case the exception is thrown immediately while in the second after a little while (but before the timeout expires). Where is the problem here? The exception means that an Accept request is being made while there is another active accept operation. Is CancelAccept() causing the problem here? And where is the problem when an incoming connection actually gets accepted? thnx |
|
E32BASE-CBase 46 panic is stray signal detected by the active scheduler. That means, a request is completed but there is no object to handle the completion. The requests may either complete normally or by cancellation.
In your case, you have two requests, but you only WaitForRequest() once. This messes up your thread's request semaphore. You should WaitForRequest() again for the completion of the other request. Since its status is KErrCancel and not KRequestPending, the wait will return immediately. Asynchronous requests are really easier to handle with CActive-derived objects, in your case one for the timer and one for the socket connection. Whichever completes first would then Cancel() the other in its RunL(). Lauri |
|
Hi,
Is it possible to resume our thread after suspending by User::WaitForRequest(). -Anand |
| anand_zain76 |
| View Public Profile |
| Find all posts by anand_zain76 |
|
am getting Error message of "E32User-CBase 46" for RSocket (CActive) tel me how to handle r solve this problem
example code: SocketIO::SocketIO(): CActive(EPriorityStandard) { requestId = 0; //connectToMSF(); } void SocketIO::connectToMSF() { TInetAddr address; TRequestStatus iStatus; buf = (char*)malloc(sizeof(char)*256); CActiveScheduler::Add(this); RHostResolver resolver; TNameEntry entry; User::LeaveIfError(iSocketServ.Connect()); User::LeaveIfError(resolver.Open(iSocketServ, KAfInet, KProtocolInetTcp)); CleanupClosePushL( resolver ); resolver.GetByName(_L("192.168.2.124"), entry); CleanupStack::PopAndDestroy();//for resolver address.SetAddress((TInetAddr::Cast(entry().iAddr)).Address()); //address.SetAddress(iaddr); address.SetPort(2800); address.SetFamily( KAfInet ); iRunState=ESocketConnected; User::LeaveIfError(clientSockId.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp)); clientSockId.Connect(address, iStatus); //User::WaitForRequest(iStatus); SetActive(); } void SocketIO::RunL() { switch ( iRunState ) { case ESocketConnected: //After Initating connection i //will be getting one msg from server if(iStatus == KErrNone) readDatastrt(); break; case EGetRequestSent: sendData(buf); break; case EDataReceived: readData(echoID); break; case EConnectionClosed: break; default: break; } // end switch } |
|
Quote:
What are you doing with the timer when the socket status is complete by this statement if(socketStatus == KErrNone) return 1; Your timer is complete later and it is not handled, you have to cancel the timer and close it. Same thing should be done for socket if the timer event come first. You should try to use AO than using WaitForRequest(). -Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
|
Quote:
I think you can't resume the thread by yourself, it is suspended by system. If you want to continue using the thread then you should use active objects. With active objects, you can make a request to service provider and after that you can continue using the thread (thread is not blocked). When the service provider has finished the task then your RunL() will be called. But with WaitForRequest() you have to wait until the service provider has finished the task. -Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
|
Hi,
How you are using SocketIO object? This should be alive until the RunL is called. If you destroy (for example) the object or the object goes out of scope then you don't have any object that can handle your request that is completed later. So don't allow the SocketIO object to go out of scope. Quote:
-Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|