Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2003

    Series60 3rd emulator: UDP receive issues

    Hello friends,

    Has anyone used the series 60 3rd edition emulator
    to do UDP send and receive? My emulator can connect
    to the internet (using browser) using the winsock type
    connection (I could not get npacket to work). But, in
    my code when the send is successful but the response
    is never received. Code snippet is attached. The same
    code works fine on S80.

    Any help will be much appreciated
    RSocketServ iSocketServ;
    TRequestStatus aStatus, bStatus;
    RSocket sock;
    TSockAddr anAddr;

    TInt ret = sock.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp);
    if(ret!=KErrNone) {
    _LIT(KError,"Socket Create failed!\n");

    TInetAddr dst(TInetAddr(INET_ADDR(192,168,1,102), 9999));
    sock.SendTo(_L8("hello"), dst, 0, aStatus);

    if (aStatus.Int() != KErrNone ) {
    _LIT(KError,"Sending Failed!\n");
    sock.RecvFrom(buf, anAddr, 0, bStatus);
    User::WaitForRequest(bStatus); // the code hangs here
    if (bStatus.Int() != KErrNone ) {
    _LIT(KSend,"Receive Failed!\n");


    I also tried the BSD style code

    int sock;
    SOCKADDR_IN sockAddr;
    SOCKADDR_IN sockAddrLocal;

    char recvTxt[128];
    char ip[32];
    int con, len, ret;
    unsigned int fromlen;
    char *dummy;

    sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
    if(sock == INVALID_SOCKET) {
    guiw_DebugN ("Socket call failed");
    return -1;

    memset(&sockAddr,0, sizeof(sockAddr));
    sockAddr.sin_family = AF_INET;

    sockAddr.sin_port = htons(9999);
    sockAddr.sin_addr.s_addr = inet_addr(server);

    len = sendto(sock, "hello", strlen("hello"), 0, (SOCKADDR *)&sockAddr,

    int cnt = 0;
    // ioctl (sock, FNONBIO, (void *)&nonblock, st);
    fcntl (sock, F_SETFL, FNONBIO);
    memset(recvTxt,0, sizeof(recvTxt));
    do {
    memset(&sockAddr,0, sizeof(sockAddr));

    fromlen = sizeof(SOCKADDR_IN);
    ret = recvfrom(sock, (char *)recvTxt, sizeof (recvTxt), 0, (SOCKADDR *)&sockAddr,

    User_After (1000000);
    } while (cnt < 600 && (strlen (recvTxt) == 0));

  2. #2
    Registered User
    Join Date
    Jan 2005
    Helsinki, Finland

    Re: Series60 3rd emulator: UDP receive issues

    As you said the same code works in S80, so I assume you did not put all code snippet here. I hope you have a address and port bound at your local udp receiving socket, something like as follows:

    TInetAddr addr;
    addr.SetPort( 9999 );
    addr.SetAddress( KInetAddrAny );
    addr.SetFamily( KAfInet );
    User::LeaveIfError( iSocket.Bind( addr ) );
    // and then you may call

    sock.RecvFrom(buf, anAddr, 0, bStatus);
    User::WaitForRequest(bStatus); // the code hangs here
    if (bStatus.Int() != KErrNone ) {
    _LIT(KSend,"Receive Failed!\n");

    You code will wait at User::WaitForRequest(bStatus); until it receive something from other device. I am suspecting that when you send a udp packet and the receiving device is not bound to a address and port, your remote dev must not receive anything. You could send only and there won't be any receiver. Hope it helps! If you haven't done this for S80, I wonder how it was working!

  3. #3
    Registered User
    Join Date
    Jun 2003

    Re: Series60 3rd emulator: UDP receive issues

    I didnot post complete code. I have the port etc. in my code. The code also works on the target device (E61). It seems the emulator has bug(s).
    Thanks for your reply though

Similar Threads

  1. Replies: 0
    Last Post: 2004-05-26, 15:11
  2. URGENT : 3rd Party app version management (Series60, c++) ?
    By TrickLo in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2002-12-09, 11:51
  3. Can I to receive message with the Series60 SDK for Symbian OS
    By roby1 in forum Bluetooth Technology
    Replies: 2
    Last Post: 2002-11-12, 01:01

Posting Permissions

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