×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    384

    Question Not getting any response for Using RSocket.

    Hi All,

    I am trying to create a simple socket applciation which will send and recieve some data from server.

    My code is written below(not very good).

    Whenever i try to run this on s60 3rd. But i never get any response.

    I try to Resolve Ip for google.com But it never shows anything.

    On seeing memory data i found a string 404 www.google.com

    But it never shows any error code.



    My Other applications using sockets(not this code) are working fine for me on emulator.

    Can Anyone tell me what can be the problem?



    Code:
    #include "SockEngine.h"
    #include <e32def.h>
    #include <e32des8.h>
    #include <Uri8.h>
    
    CSocketEngine::CSocketEngine() : CActive(EPriorityStandard)
    ,iPtrTempBuffer(NULL,0)
    {
    
    	CActiveScheduler* sceduler = new CActiveScheduler();
    	CActiveScheduler::Install(sceduler);
    	CActiveScheduler::Add(this);
    }
    
    CSocketEngine::~CSocketEngine()
    {
    	if(IsActive())
    	{
    		Cancel();
    	}
    }
    
    
    
    void CSocketEngine::ConstructL()
    {
    
    
    	TInt err = 0;
    	err = iServer.Connect();
    
    
    		
    	err  = 	iSocketClient.Open(iServer ,KAfInet, KSockStream, KProtocolInetTcp);
    	err = iHostResolver.Open(iServer, KAfInet, KProtocolInetTcp);
    	
    	
    	_LIT8(aUrl,"http://google.com");
    	
    	TUriParser8 url;
    	url.Parse(aUrl);
    	iServerName.Zero();
    	iServerName.Copy(url.Extract(EUriHost));		
    			
    	iStatus = KRequestPending;		
    	iHostResolver.GetByName(iServerName, iNameEntry, iStatus);
    
    	m_pStatus = EResolving;
    
    	SetActive();
    	CActiveScheduler::Start();
    			
    
    }
    
    void CSocketEngine::RunL()
    {
    	switch(m_pStatus)
    	{
    	
    
    		case EInitializing:
    		{
    			if(iStatus = KErrNone)
    			{
    				m_pStatus = EOpening;
    				iSocketClient.Open(iServer ,KAfInet, KSockStream, KProtocolInetTcp);
    				SetActive();
    			}
    		}
    		break;
    
    		case EResolving:
    		{
    			if(iStatus == KErrNone)
    			{
    				m_pStatus = EConnecting;
    				m_nDesAdd = iNameEntry().iAddr;
    				m_nDesAdd.SetPort(80);
    				iSocketClient.Connect(m_nDesAdd ,iStatus);
    				SetActive();
    			}
    		}
    		break;
    
    		case EConnecting:
    		{
    			if(iStatus == KErrNone)
    			{
    			_LIT8(KMyREquest, "abc");
    				m_pStatus = EConnected;
    				iStatus = KRequestPending;
    				iSocketClient.Write(KMyREquest , iStatus);
    				SetActive();
    			}
    
    		}
    		break;
    
    		case EConnected:
    		{
    
    			{
    				if (iTempBuffer)
    					delete iTempBuffer;
    				iTempBuffer = NULL;
    				iPtrTempBuffer.Set(NULL,0,0);
    
    				iTempBuffer = HBufC8::NewLC(1024);
    				iPtrTempBuffer.Set(iTempBuffer->Des());
    				m_pStatus = EConnected;
    				iStatus = KRequestPending;
    				iSocketClient.RecvOneOrMore(iPtrTempBuffer, 0,iStatus,iLen);
    				SetActive();
    				CleanupStack::Pop();
    			}
    
    		}
    		break;
    		
    		default:
    		if(iStatus == KErrNone)
    		{
    			
    		}
    	}
    
    }
    
    void CSocketEngine::DoCancel()
    {
    	Cancel();
    }

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

    Re: Not getting any response for Using RSocket.

    1st. code

    Code:
    err = iHostResolver.Open(iServer, KAfInet, KProtocolInetTcp);
    you need change

    Code:
    err = iHostResolver.Open(iServer, KAfInet, KProtocolInetUdp);
    2nd, the app is console app, or you don't need create and install CActiveSchedule.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    384

    Question Re: Not getting any response for Using RSocket.

    Hi Sir,

    thanks for replying.

    Please tell me why can't i use tcp and use udp.

    What's the reason behind this?

    Is there any sense of using udp ovr tcp?

    Also i somewhere read that fro console paalication we need to install acctivesceduler and not for gui/ui application.

    Thanks
    Last edited by dinesh547; 2008-10-24 at 09:20.

  4. #4
    Registered User
    Join Date
    Nov 2007
    Posts
    384

    Question Re: Not getting any response for Using RSocket.

    Hi All,

    Now i am able to resolve the ip but.

    Whenever i write follwing data to google.com

    GET /index.html HTTP/1.0\n\n

    i always get keof(-25) in istatus of RecvOneOrMore();

    Can anyone tell y i ma getting KEof without reading a single byte from server.

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

    Re: Not getting any response for Using RSocket.

    Quote Originally Posted by dinesh547 View Post
    Hi Sir,

    thanks for replying.

    Please tell me why can't i use tcp and use udp.

    What's the reason behind this?

    Is there any sense of using udp ovr tcp?

    Also i somewhere read that fro console paalication we need to install acctivesceduler and not for gui/ui application.

    Thanks
    dns query use udp protocol, not use tcp, so use the value.

    and send http request , need sime other fileds.
    like: "GET /index.htm HTTP/1.1\r\nAccept: */*\r\nHost: x.x.x.x\r\nConnection: Keep-Alive\r\n\r\n".
    maybe web server treat your request as attack request.
    Last edited by qxiaoyuan; 2008-10-24 at 11:11.
    ----------------------------
    坚持学习, 坚持编码
    http://www.devdiv.net/
    qxiaoyuan

  6. #6
    Registered User
    Join Date
    Nov 2007
    Posts
    384

    Smile Re: Not getting any response for Using RSocket.

    Hi sir,

    Sorry For all Trouble.

    Actually there is no problem in code.

    I am looking at wrong data.which causes all this trouble.

    And we don't need to use udp to resolve hostname tcp also works for me.

    Anyay thanks for support friend.
    Last edited by dinesh547; 2008-10-24 at 11:18.

Similar Threads

  1. Handling asynch USSD response from operator
    By espenwe in forum Symbian Networking & Messaging (Closed)
    Replies: 9
    Last Post: 2009-02-05, 08:46
  2. Problem retreiving custom HTTP response header
    By hmeet2 in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2007-01-03, 09:35
  3. Nokia 30 response format
    By richard_h_t in forum Nokia M2M
    Replies: 0
    Last Post: 2005-07-06, 08:23
  4. 'Response Unknown' when downloading midlet
    By Weevil in forum Mobile Java General
    Replies: 3
    Last Post: 2004-05-30, 17:01
  5. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46

Posting Permissions

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