×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    sending data thrught socket, c++

    Hi all, this is my first post

    I use Carbide.c++ IDE for development.
    I am trying to make simple example of connecting to server from the phone. By reading documentation i got to
    Code:
    S60 3rd Edition SDK for Symbian OS, Supporting Feature Pack 1, for C++ > Symbian OS Library for Application Developers (Symbian OS v9.2) > Symbian OS guide > Networking > Using TCP/IP (INSOCK)
    where socket communication is explained, but I find our documentation not so complete.
    This is what i got so far:
    * instantiate RSocketServ and RSocket
    * call RSocketServ::Connect()
    * call RSocket::Open()
    * call RSocket::Connect() specifying server address
    * now send data with RSocket::Send() and receive with RSocket::Recv()

    Can someone help with more details ? because documentation explains this process in very abstract way.

    I also don`t understand mechanism behind 'asynchronously' calling methods. There is no callback parameter ??

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

    Re: sending data thrught socket, c++

    Code:
    RSocketServ sockserv;
    sockserv.Connect();
    CleanupClosePushL(sockserv);
    
    RSocket socket;
    User::LeaveIfError(socket.Open(sockserv,KAfInet,KSockStream,KProtocolInetTcp));
    CleanupClosePushL(socket);
    
    TInetAddr addr(1234);
    addr.Input(_L("127.0.0.1"));
    TRequestStatus stat;
    socket.Connect(addr,stat);
    User::WaitForRequest(stat);
    User::LeaveIfError(stat.Int());
    
    socket.Write(_L8("Hello"),stat);
    User::WaitForRequest(stat);
    User::LeaveIfError(stat.Int());
    
    CleanupStack::PopAndDestroy(2); // socket, sockserv
    The downside is that User::WaitForRequest blocks the complete thread (e.g. a GUI application will become unresponsive during the communication), so real life code wraps these happenings into an active object.
    Check S60Ex\Chat in SDK for such an example.

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    2

    Smile Re: sending data thrught socket, c++

    Thanks wizard_hu_ that is all I needed will implement it with active object.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: sending data thrught socket, c++

    can any one provide a code for sending and recieving messages through sockets. or any complete example

  5. #5
    Regular Contributor
    Join Date
    Jul 2008
    Posts
    136

    Smile Re: sending data thrught socket, c++

    Quote Originally Posted by Asif Nazir View Post
    can any one provide a code for sending and recieving messages through sockets. or any complete example
    u can SDK example SIPExample -->socket Engine for the same ...

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,684

    Re: sending data thrught socket, c++

    Or Chat example.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    187

    Re: sending data thrught socket, c++

    Thks, its help full.

Similar Threads

  1. Replies: 2
    Last Post: 2008-07-03, 15:29
  2. Socket : server gets data only when I exit client app
    By viku_006 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2007-06-25, 12:26
  3. GPRS connection problems on 6600..
    By suckho in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2005-12-02, 14:00
  4. Nokia 6600 Socket Server send delay Problem
    By dicson_hu in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-10-31, 07:37

Posting Permissions

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