×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Socket server in S60 2.0 emulator and socket client on Windows

    I am writing Socket server EXE application for S60 2nd edition (initial release) phone

    I installed:
    1. s60_sdk_v2_0_CW
    2. Carbide.C++ 1.2
    3. Ethernet Plug-in for Series 60 SDK 2.0
    and configured ethernet plugin to use my computer's WLAN interface.
    My computer's IP: 192.168.1.10
    IP address I gave to Emulator: 192.168.1.11
    Then I launched the emulator and I am successful in browsing internet in emulator.

    Now when I run following code:
    Code:
        TInetAddr InetAddr(KInetAddrAny, 5000);
        RSocketServ SocketServObject;
        
        User::LeaveIfError(SocketServObject.Connect());
        CleanupClosePushL(SocketServObject);
        
        RSocket SocketListner;
        User::LeaveIfError(SocketListner.Open(SocketServObject, KAfInet, KSockStream, KProtocolInetTcp));
        User::LeaveIfError(SocketListner.Bind(InetAddr));
        User::LeaveIfError(SocketListner.Listen(10));
        
        ConsoleObject->Printf(_L("Server started"));
        
        TRequestStatus RequestStatus;
        for(;;){
            RSocket SocketClient;
            SocketClient.Open(SocketServObject);
            SocketListner.Accept(SocketClient, RequestStatus); 
            User::WaitForRequest(RequestStatus);
            if(RequestStatus != KErrNone){
                User::Leave(KErrGeneral);
            }
            ConsoleObject->Printf(_L("Client connected\n"));
            ServeClient(SocketClient);
        }
    I can see the message "Server started" in the emulator.
    But when I connect from windows cmd.exe like this:
    telnet 127.0.0.1 5000
    or telnet 192.168.1.10 5000
    or telnet 192.168.1.11 5000

    I am unable to connect...
    Please tell me what else I need to do...

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    telnet 127.0.0.1 5000
    or telnet 192.168.1.10 5000
    or telnet 192.168.1.11 5000
    Try the above from another PC/host on the same ethernet segment. When I was working with Symbian devices, Windows network/pcap had sometimes problems routing packets within the same host (I don't know the cause...).

  3. #3
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    I tried it but it didn't work.

    Actually, when I browse internet in emulator, before opening first website, it displays a message "Connecting via" and a symbol "G" appears.

    But when I open a server socket in my application, it doesn't display any such message.

    I also tried using RConnection and passing RConnection variable to SocketListner.open, but no success.

    what to do...

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    14

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    Quote Originally Posted by arpit2agrawal View Post

    But when I open a server socket in my application, it doesn't display any such message.
    oh right, just opening the listening socket does not drive up any access points.

    You need to drive up interface. Listen doesn't care who does it. Thus, you can start your server app and then just drive the desired IAP (wlan) up using the browser. (Or your server app could use RConnection start somewhere).

    (I assume your InetAddr in bind contains 0.0.0.0 or even better "unspecified" -- if you put explicit 192.168.1.10, it is pointless and only causes Bind to succeed only if the interface with that address is fully up). Always use only the port in inet address for server sockets, leave address unspecified.

  5. #5
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    Quote Originally Posted by msa22 View Post
    Thus, you can start your server app and then just drive the desired IAP (wlan) up using the browser.
    I cannot open anything in the emulator when my application is running... pressing the "Application Key" doesn't show the applications menu...

    Quote Originally Posted by msa22 View Post
    (Or your server app could use RConnection start somewhere).
    I tried using Socket. But no success. Here is the code:
    Code:
    LOCAL_C void StartInterfaceL(RSocketServ SocketServObject){
        TRequestStatus RequestStatus;
        TInetAddr InetAddr;
        
        RHostResolver HostResolver;
        TNameEntry NameEntry;
        TNameRecord NameRecord;
        User::LeaveIfError(HostResolver.Open(SocketServObject, KAfInet, KProtocolInetTcp));
        CleanupClosePushL(HostResolver);
        User::LeaveIfError(HostResolver.GetByName(_L("google.co.in"), NameEntry));
        NameRecord = NameEntry();
        InetAddr = TInetAddr::Cast(NameRecord.iAddr);
        InetAddr.SetPort(80);
        CleanupStack::Pop(&HostResolver);
        HostResolver.Close();
        
        RSocket Socket;
        User::LeaveIfError(Socket.Open(SocketServObject, KAfInet, KSockStream, KProtocolInetTcp));
        CleanupClosePushL(Socket);
        Socket.Connect(InetAddr, RequestStatus);
        User::WaitForRequest(RequestStatus);
        if(RequestStatus != KErrNone){
            User::Leave(KErrGeneral);
        }
        CleanupStack::Pop(&Socket);
    }
    But it leaves when executing red line

    Please tell me what to do... I want to develop this application for Nokia 6600... that's why I am using s60_sdk_v2_0_CW SDK and its emulator...

    Quote Originally Posted by msa22 View Post
    (I assume your InetAddr in bind contains 0.0.0.0 or even better "unspecified" -- if you put explicit 192.168.1.10, it is pointless and only causes Bind to succeed only if the interface with that address is fully up). Always use only the port in inet address for server sockets, leave address unspecified.
    I used KInetAddrAny which is 0.0.0.0 I also tried with unspecified...

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

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    You may want to check that error code which causes User::LeaveIfError to actually leave. Since you have a console object, it might be wiser to simply Printf it - and waiting for a keypress for example - than leaving immediately.
    In case of S60 2nd (and 1st) edition, .exe-s ("console executables") use a separate (blue screen) emulator, that is why you can not switch to the menu for example, so it is normal.

  7. #7
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    I tried executing code posted in my first post on emulator of S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en
    And then I did
    telnet 127.0.0.1 5000
    and it worked fine. Without bringing up any interface.

    There is some issue with emulator of s60_sdk_v2_0_CW

    Anyways, I will write my application using S60_3rd_Edition_SDK_Feature_Pack_2_v1_1_en and then port it to s60_sdk_v2_0_CW... if someone knows a better option then please let me know

  8. #8
    Super Contributor
    Join Date
    Jan 2008
    Location
    Amravati, India
    Posts
    546

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    Quote Originally Posted by wizard_hu_ View Post
    You may want to check that error code which causes User::LeaveIfError to actually leave.
    The error code is -2

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: Socket server in S60 2.0 emulator and socket client on Windows

    Negative numbers are here: http://wiki.forum.nokia.com/index.php/Error_codes
    Since -2 is not a really detailed one, you may want to check the logfile of the emulator (http://wiki.forum.nokia.com/index.php/Epocwind.out), it may contain traces of activities of the Socket Server. In fact it is absolutely not sure that the "blue screen" emulator supports all kind of socket functionality - though simple TCP/IP should work, my doubts are more about the RHostResolver.

    About the other post: yes, 3rd edition emulator works in "full feature" mode even in case of "console" .exe-s.

Posting Permissions

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