×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    11

    why my socket server can not accept more request?

    Hi All:

    I have dev a local socket server on symbian 3rd edition, unfortunatly, it does not work well. it just correctlly accept the first request from client, and absolutly ignor all the following request. what happend and why?

    server code:

    CHttpSocketEngine is main class, derive from CActive

    Code:
    void CHttpSocketEngine::StartListeningL(TInt myPort, TBool nomsg)
    {
    	TInt err;
    
    	err = iSocketServ.Connect();
    	if (err != KErrNone)
    	{
    		return;
    	}
    
    	if ((err = iServerSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp)) != KErrNone)
    	{
    		iSocketServ.Close();
    		return;
    	}
    
    	if ((err = iServerSocket.SetLocalPort(myPort)) != KErrNone)
    	{
    		iServerSocket.Close();
    		iSocketServ.Close();
    		return;
    	}
    
    	if ((err = iServerSocket.Listen(1)) != KErrNone)
    	{
    		iServerSocket.Close();
    		iSocketServ.Close();
    		return;
    	}
    
    	if (iClientSocket.Open(iSocketServ) != KErrNone)
    	{
    		iServerSocket.Close();
    		iSocketServ.Close();
    		return;
    	}
    
    	iServerSocket.Accept(iClientSocket, iStatus);
    	SetActive();
    	
    	listening = ETrue;	
    }
    
    
    void CHttpSocketEngine::RunL()
    {
    	if (iStatus != KErrNone)
    	{
    		iClientSocket.Close();
    		iServerSocket.Close();
    		listening = EFalse;
    		StartListeningL(EFalse);
    		return;
    	}
    	HandleClientL(iClientSocket);// to handle the data 
    	iClientSocket.Close();
    	
    	if(closing)
    	{
    		User::Exit(0);
    	}
    	
    	if (iClientSocket.Open(iSocketServ) != KErrNone)
    	{
    		iServerSocket.Close();
    		iSocketServ.Close();
    		listening = EFalse;
    		return;
    	}
    	 // let the ServerSocket back to accept status,but actually, it does work, why
    	iServerSocket.Accept(iClientSocket, iStatus); 
    	SetActive();  
    }

    is it possible that some thing wrong with the client ? thx!
    Last edited by wizard_hu_; 2010-11-25 at 10:45. Reason: [CODE] and [/CODE] tags

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: why my socket server can not accept more request?

    Similar code works for me well, so it might be the client causing the problem.
    The StartListeningL(EFalse); in the error handling branch of RunL seems a bit strange (or at least it calls some other method than the one presented in your post), but I think it does not often gets invoked.

Similar Threads

  1. socket accept error
    By GFYsweetwood in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2009-11-18, 09:02
  2. How to make Socket Server understand Get ,Post request? Please
    By alicenan88 in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2009-10-21, 17:13
  3. Is it possible to accept (or reject) a BT connection request to device by a Program?
    By rzmadadi in forum Symbian Networking & Messaging (Closed)
    Replies: 12
    Last Post: 2008-12-15, 13:53
  4. J2ME accept socket connection
    By tyrael in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-02-08, 00:41
  5. How to use socket bind and accept the PC
    By 830809 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-05-11, 22:32

Posting Permissions

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