×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    13

    Question RSocket Connection Problem

    hi all,

    i'm developing a TCP client application and found there are two problem with RSocket.
    1. while connecting to a non-existing ip address with RSocket::Connect(iAddr, iStatus), RSocket will block in Connect() for 20~30 seconds then next step over SetActive(). This problem won't happened on target device.(I realize this problem had been asked on the forum, but i did't see the problem has been cleared)
    2. there are two ip address, one(say, A) can be reached and the other(say, B) can't. if RSocket first connect to B then connect to A, it will result in:

      RSocket connect to B --> enter RunL with error code -33(time out) --> RSocket connect to A --> enter RunL with error code -33

      that's wield! i'm sure that host A can be reached.

      the problem can be solved if i do RSocket::Close() and then RSocket::Open() before connecting to A. that is,

      RSocket connect to B --> enter RunL with error code -33(time out) --> do RSocket::Clsoe() --> do RSocket::Open() --> RSocket connect to A --> enter RunL with KErrNone

      however, i dont think that's a good metholody...
      Socket should be reusable, even if there are something wrong(eg, connection error) with it, isn't it ?


    this is my code snippet

    cpp
    Code:
    TEST* TEST::NewL()
    {
    	TEST* self = new(ELeave) TEST;
    	CleanupStack::PushL(self);
    	self->ConstructL();
    	CleanupStack::Pop(self);
    	return self;
    }
    
    void TEST::ConstructL()
    {
    	iSocketServ.Connect();
    	iConn.Open( iSocketServ ); 
    	iConn.Start();
    	iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp,iConn);	
    }
    
    TEST::TEST() : CActive(0)
    {
    	CActiveScheduler::Add(this);
    }
    
    TEST::~TEST()
    {
    	Cancel();
    }
    
    void TEST::RunL()
    {
    	User::LeaveIfError(iStatus.Int());
    	CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
    	informationNote->ExecuteLD(_L("connected"));
    }
    
    void TEST::DoCancel()
    {
    	
    }
    
    TInt TEST::RunError(TInt aError)
    {
    	TBuf<64> msg;
    	msg.Format(_L("err: %d"), aError);
    	CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
    	informationNote->ExecuteLD(msg);
    
    	return 0;
    }
    
    void TEST::ConnectL(TInetAddr& aAddr)
    {
    	iAddr = aAddr;
    	iSocket.Connect(iAddr, iStatus);
    	SetActive();
    }
    and header

    Code:
    class TEST :public CActive
    {
    	public:
    		static TEST* NewL();
    		~TEST();
    	private:
    		void ConstructL();
    		TEST();
    	protected:
    		void RunL();
    		void DoCancel();
    		TInt RunError(TInt aError);
    	public:
    		void ConnectL(TInetAddr& aAddr);
    	private:
    		RSocket iSocket;
    		RSocketServ iSocketServ;
    		RConnection iConn;	
    		TInetAddr iAddr;
    };
    thanks in advance,

    any comment will be appreciated

  2. #2
    Super Contributor
    Join Date
    Jul 2007
    Location
    ShenZhen, China
    Posts
    4,346

    Re: RSocket Connection Problem

    symbian tcp/ip support not perfect.
    1. it's maybe symbian emulator and winsows os adapter bugs.

    and symbian have an other bugs, if use start a rconnection, and stop quickly, try some times.
    symbian so will block, only plug out batteries:
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: RSocket Connection Problem

    1. RSocket::Connect is a wrapped RSubSessionBase::SendReceive - it does not check if you pass valid/invalid, existing/non-existing argument, thus it can not block your code

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    13

    Re: RSocket Connection Problem

    Quote Originally Posted by wizard_hu_ View Post
    1. RSocket::Connect is a wrapped RSubSessionBase::SendReceive - it does not check if you pass valid/invalid, existing/non-existing argument, thus it can not block your code
    hi wizard_hu,

    I agree with ur point of view, but the fact is it blocks.
    As u can see from my code snippet, can u kindly point out what's wrong with my code then made it block?

    i'm wondering that is it possible that
    when the first time RSocket connect to a remote host, RSocket will synchronously bind(i did not call the bind() function explicitly) to a local address, thus made it block?

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: RSocket Connection Problem

    The only method that really takes some time is the RConnection::Start-variant you use.
    Actually why do you think that your code blocks? RSocket::Connect surely does not provide its result immediately, but your application can freely run in the meantime.
    A thing you can check if you can do anything else when the code apparently hangs - say switch to the application menu, return to the idle screen, etc. Just to eliminate the possibility of that the whole device blocking.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    13

    Re: RSocket Connection Problem

    Quote Originally Posted by wizard_hu_ View Post
    The only method that really takes some time is the RConnection::Start-variant you use.
    Actually why do you think that your code blocks? RSocket::Connect surely does not provide its result immediately, but your application can freely run in the meantime.
    A thing you can check if you can do anything else when the code apparently hangs - say switch to the application menu, return to the idle screen, etc. Just to eliminate the possibility of that the whole device blocking.
    okey, the BLOCK means
    when i set break points at iSocket.Connect(iAddr, iStatus) and SetActive() then run the application, this results in:
    debug mode step on Connect() --> step over by press the hotkey(F10 for codewarrior, F6 for Carbide) --> the emulator hangs and the UI(eg, menu) can't be interacted --> after 20 seconds, the emulator step on SetActive() --> RunL() get called
    This is exactly that the BLOCK i mean by.

    For an asynchronous function, when i call Connect(), it should:
    debug mode step on Connect() --> step over by press the hotkey --> step on SetActive() and the UI can be interacted --> after some moments, the emulator step on RunL().

    besides, wizard_hu, do u have any idea about my question 2(why RSocket can't be reusing after failing connecting to a remote host)?

  7. #7
    Regular Contributor
    Join Date
    Oct 2007
    Posts
    61

    Re: RSocket Connection Problem

    Hi,

    In debug mode try to see if the new addr of A is getting assigned to iAddr.

    Else try with socket bind() call before connect.

    By default socket isnt reusable automatically if its bound to A then to B.

    -Sudhix

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,752

    Re: RSocket Connection Problem

    That delay may be an issue of the emulator and its IP stack implementation. Especially since the Socket Server might not initialize its protocol modules until you do not ask it to do that.

Similar Threads

  1. j2se server j2me client bluetooth connection problem
    By bepolat in forum Mobile Java Networking & Messaging & Security
    Replies: 6
    Last Post: 2010-07-14, 11:05
  2. E65 SIP connection problem
    By Razzle in forum VoIP
    Replies: 20
    Last Post: 2010-04-05, 13:10
  3. Connection problem while browsing web from a middlet
    By oleberre in forum Mobile Java Networking & Messaging & Security
    Replies: 3
    Last Post: 2007-02-23, 12:29
  4. Bluetooth direct connection problem
    By mrautane in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-02-14, 06:33
  5. Nokia 6310i & Mac 17" powerbook bluetooth connection problem
    By scarylittlevoices in forum Bluetooth Technology
    Replies: 1
    Last Post: 2003-08-21, 14:48

Posting Permissions

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