×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605

    Sending data using Sockets

    What is the process of sending data using Sockets .

    I have made a connection using Socket.Connect()

    Now what to do after this ..
    Becase when i do something like

    if(iRunState==ESocketConnected)
    {
    iSocket.Write(aDesc,iStatus);
    SetActive();
    iRunState=ECommandSent;
    }

    The program crashes......

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,165
    what is the error note shown during the crash ?

    Also is the aDesc a member variable of the class ?, it should really be, since othervise it could go out-of-scope during the write process.

    yucca

  3. #3
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    oho ..
    It is not the member of the class .
    I m just passing it as a perimeter in a function .
    Okie .. i wil make it a member of the class now .

  4. #4
    Super Contributor
    Join Date
    Feb 2004
    Location
    Dallas
    Posts
    605
    Hi Yucca now i have made it a member of the class and this is the latest situation ....


    this is the code ..........

    Code:

    //in Connect Function
    // Connect to the server, asynchronously
    iSocket.Connect( iInetAddr, iStatus );
    SetActive();



    //in RunL()
    Code:

    void CConnection::RunL()
    {
    switch ( iRunState )
    {
    case ESocketConnected:
    //User::LeaveIfError(iStatus.Int());// leave on bad return code
    if(iStatus==KErrNone)
    {
    iRunState=ESocketConnected;
    _LIT(KSocketConnnectedMessage, "Socket Connected");
    CEikonEnv::Static()->AlertWin(KSocketConnnectedMessage);

    }
    break;



    and in Send data ffunction
    Code:

    void CConnection::Send(const TDesC8& aDesc)
    {
    iSndBuffer=aDesc;
    if(iRunState==ESocketConnected)
    {
    iSocket.Write(iSndBuffer,iStatus);
    SetActive(); .\\Leaves here .......
    iRunState=ECommandSent;
    }
    }

    also when i reach the line setActive the connection has not been made.
    As i m testing it on a java server where it shows when connected.
    But when i m checking iRunState==ESocketConnected
    how is it possible that without making the connection it executes the "iSocket.Write(iSndBuffer,iStatus);"

Posting Permissions

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