Groups > Symbian > Symbian EPOC connect > can anyone help me ?????




can anyone help me ?????

can anyone help me ?????
Wed, 12 Jul 2006 13:07:24 +053
Hi ....
      Thanks 4 ur reply...this is the code i did in the server....& in the 
receiving http header request part....plz tell me where i went wrong ....

server code :
#include "ClientServer.h"
#include "ClientRecv.h"
#include <in_sock.h>

_LIT(KConnFail,"Connection Fails");
_LIT(KConnect,"Connected");
_LIT(KSuccess,"Success");

CClientServer* CClientServer::NewL()
{
   CClientServer* self = new (ELeave) CClientServer;
   CleanupStack::PushL(self);
   self->ConstructL();
   CleanupStack::Pop(self);
   return self;
}

void CClientServer::ConstructL()
{
 CActiveScheduler::Add( this );
 StartServerL();
}

CClientServer::CClientServer()
 : CActive(EPriorityStandard)
{
}

void CClientServer::StartServerL()
{
  if(!IsActive())
  {
 iSocketServer.Connect();

    TInetAddr iListenAddr(KInetAddrAny,9393);

 iSocket.Open(iSocketServer,KAfInet,KSockStream,KProtocolInetTcp);
// TPckgBuf<TUint> flags;
// flags() = KSockSelectRead;
// iSocket.Ioctl(KIOctlSelect,iStatus, &flags, KSOLSocket);
 iSocket.Bind(iListenAddr);
 iSocket.Listen(6);
 iClient.Open(iSocketServer);
 iSocket.Accept(iClient,iStatus);
 SetActive();
  }
}

CClientServer::~CClientServer()
{
 Cancel();
 delete iRecv;
 iRecv=NULL;
 iClient.Close();
 iSocket.Close();
 iSocketServer.Close();
}

void CClientServer::DoCancel()
{
  iSocket.CancelAccept();
}

void CClientServer::RunL()
{
 iRecv = CClientRecv::NewL(iSocket);
 iRecv->RecvMessageL();
}

**********************************************

#include "ClientRecv.h"
#include "ClientServer.h"

_LIT(KDirName,"C:\\nokia\\");
_LIT(KFileName,"C:\\nokia\\mamus.txt");
_LIT(KReceiveFail,"Receive fails");
_LIT(KReceiveSuccess,"Receive Success");

CClientRecv* CClientRecv::NewL(RSocket& aSocket)
{
    CClientRecv* self = new(ELeave) CClientRecv(aSocket);
    CleanupStack::PushL( self );
    self->ConstructL();
 CleanupStack::Pop( self );
    return self;
}

CClientRecv::CClientRecv(RSocket& aSocket)
 : CActive(CActive::EPriorityHigh),iSocket(aSocket)
{
}

CClientRecv::~CClientRecv()
{
 Cancel();
 }

void CClientRecv::ConstructL()
{
 CActiveScheduler::Add(this);
 }

void CClientRecv::RunL()
{
 if(iStatus == KErrNone)
 {
  User::InfoPrint(KReceiveSuccess);

 }
 else
     User::InfoPrint(KReceiveFail);
}

void CClientRecv::DoCancel()
{
 iSocket.CancelRecv();
}

void CClientRecv::RecvMessageL()
{
 if(!IsActive())
 {
 fsSession.Connect();
 CleanupClosePushL(fsSession);
 file.Replace(fsSession,KFileName,EFileWrite);
// iSocket.SetOpt(KSORecvBuf, 1, 80);
TBuf8<1024> buffer;
 iSocket.RecvOneOrMore(buffer,0,iStatus,iLen);
 User::WaitForRequest(iStatus);
 file.Write(buffer);
 file.Close();
 CleanupStack::PopAndDestroy(&fsSession);
 SetActive();
 }
}



----- Original Message ----- 
From: "sundar" <sundar_svb@india.com>
Newsgroups: discussion.epoc.cplusplus
Sent: Saturday, July 08, 2006 11:14 AM
Subject: Junk Values - Http Request Header Content Pblm


> Hi ....
>        i'm doing a server in symbian in which it listens for the > 
> connection> from a browser set with loopback address & port no 9393

> ....when i open
> the
> browser & type any site in it ...for example if i type "
www.google.com"
> this request shld be accepted and the information such as Get Host Http
> ........... and all these shld be received in a buffer & written to a
file
> ......here is the code snippet wat i had done........file is created but
> garbage is there in it....full garbage is there....this is the code
> snippet
> i used to receive content & store in the file.....
>
> void ReceiveMessageL()
> {
> fsSession.Connect();
> fsSession.MkDirAll(KDirName);
> file.Replace(fsSession,KFileName,EFileWrite);
>
> TBuf8<1024> buffer;
> iSocket.RecvOneOrMore(buffer,0,iStatus,iLen);
>
> User::WaitForRequest(iStatus);
> file.Write(buffer);
> file.Close();
> fsSession.Close();
> }
>
> This is the file content :::::
>
> ױPP@
>   &A       ,*A x*A           h>A P@A ">A  ?A BA <?A
  lNA pU@
> o   ?A (UP?A pU@ >A                     ?A l   ?A >A pU@
">A >A T
> ?A           xUP    8   ?A                        ?A pU@
> 0  lNA pU@                   lNA (UPBA pU@ l?A
> tAA
>   lNA "?A pU@ <?A XAA   lNA           xUP      lNA

> pAA
> ~   OAA PPP
>           8@A 
>                  ?                          
>   ?A    OAA   OAA 3PpU@                     
>        
>   @A
>   ">A                                            3PpU@
>           ?              lNA                       lNA pU@
> ?   OBA ױPP@     T
>
>       )A # (A       ~CA
>   0   "CA pU@                    "CA  V@    "CA @
>
>
>
>

Post Reply
about | contact