×

Discussion Board

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

    How to bind UDP server sockets?

    Hi,


    I'm going to develop a UDP server socket on Series 60 (Symbian 6.1). This means the Socket should be bind to any address and a specific port.
    For this I
    (1) created a SocketServer,
    (2) connected the Socket Server
    (3) created a Socket:
    myUDPServerSocket.open(socksrv, KAfInet, KSockDatagram, KProtocolInetUdp);
    (4) created a TInetAddr:
    Code: myLocalAddr = new TInetAddr(KInetAddrAny, 1234);

    (5) bind the socket to that address:
    Code: myUDPServerSocket.Bind(myLocalAddr);


    This binding seams not be working.
    I use the emulator and I have connection to the network (I can send packets). I even I can receive packets at this sending socket (I used ethereal to find out the port of this sending socket).

    What's wrong?

    Thx for helping!

  2. #2
    Registered User
    Join Date
    May 2004
    Posts
    18

    RSocket Bind leave

    Hi,

    I have the same problem. When I try to bind KInetAddrAny to RSocket, it will leave with error code KErrInUse. I even try to close and open it agian, it will also get KErrInUse.

    Have you resloved the problem, please let me know. If somebody else can help us, thank you very much.

    TProtocolDesc desc;
    User::LeaveIfError(iServer.FindProtocol(aProtocol, desc));

    User::LeaveIfError(iListener.Open( iServer
    , desc.iAddrFamily
    , desc.iSockType
    , desc.iProtocol
    ));

    iListenAddr = KInetAddrAny;
    TInt err(iListener.Bind(iListenAddr));
    if( err == KErrInUse )
    {
    iListener.CancelAll();
    iListener.Close();
    RSocketServ Server;
    err = Server.Connect();
    User::LeaveIfError(err);
    User::LeaveIfError(iListener.Open( Server
    , desc.iAddrFamily
    , desc.iSockType
    , desc.iProtocol
    ));
    TInetAddr serverAddr(INET_ADDR(0,0,0,0),80);
    err=iListener.Bind(iListenAddr);
    User::LeaveIfError(err);
    }

  3. #3
    Registered User
    Join Date
    Oct 2004
    Posts
    1

    UDP Bind/SendTo errors

    Hi Guys,

    am having a similar problem, but I went past Bind call in UDP. my problem comes later in SendTo() call

    /*
    * RSocketServ aServer is Open() and Connect()ed.
    */
    void CUdpSendAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
    {

    // some cases...

    case EUdpSendCmdAppTest:
    {

    RSocket fd; TInt err;

    // define, open, bind a local socket desc
    fd.Open(aServer, KAfInet, KSockDatagram, KProtocolInetUdp);
    if ( fd.Bind(*src) != KErrNone )
    {
    fd.Close();
    iEikonEnv->InfoMsg(_L("error_opening_socket"));
    User::LeaveIfError(err);
    }


    TRequestStatus aStatus;
    TInt len = 500;
    TSockXfrLength aLen = len;

    // set the constant data buffer
    TPtrC8 aDesc ( (TUint8 *) "TEST data for UDP of size 350");

    // set the dest address: udp/ip addr
    TSockAddr dst(TInetAddr(INET_ADDR(208,253,206,44), 5060));

    iEikonEnv->InfoMsg(_L("Connectinng to a remote server..."));
    fd.SendTo(aDesc, dst, KSIConnectionLess|KSIMessageBased, aStatus, aLen);

    if ( aStatus.Int() != KErrNone )
    {
    iEikonEnv->InfoMsg(_L("Send Unsuccessfull"));
    User::LeaveIfError(aStatus.Int());
    }
    else
    {
    iEikonEnv->InfoMsg(_L("Send Successfull"));
    }

    fd.Close();
    break;
    }

    // other cases...

    }
    } /* end of HandleCommand() */

Posting Permissions

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