×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    102

    UDP/STUN Problem

    I am tring to to implement STUN like app.
    the first stage is without NAT.

    I am using one socket for both recieving and sending with RecvFrom and SendTo.
    I have 2 symbian phone use as peer and PC server.
    both phone connect the server and retrive the addresses of each other.

    then I start Ping the other peer.
    for all of this I use the socket.

    when both peer uses the same local port (I Bind to port first to listen) I get the pings.
    If I don't Bind, or bind with port = 0 (i.e. retrive random port)
    I don't recieve the ping?

    any idea?

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

    Re: UDP/STUN Problem

    Binding is necessary for receiving something, why would it be otherwise on Symbian?

  3. #3
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    102

    Re: UDP/STUN Problem

    I try only with the server.
    at the server, I opened new socket every msg and didn't get the respones.

    2 possible that i thogth of:
    1. I can't use the same socket for sending and recieving (even with diffrent AO)
    2. when using a socket and reciving one packet, I can't use this same socket to recive packet from other addresses?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: UDP/STUN Problem

    Quote Originally Posted by nire123 View Post
    1. I can't use the same socket for sending and recieving (even with diffrent AO)
    Actually I can. RSocket is prepared for full-duplex use, you can send and receive at the same time.
    2. when using a socket and reciving one packet, I can't use this same socket to recive packet from other addresses?
    If you bind to KInetAddrAny (or do not bind at all, just SetLocalPort), the given socket will accept packets from any address.

  5. #5
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    102

    Re: UDP/STUN Problem

    I keep strugle with this..

    I send ping to the server and in the server I send two respones.
    the first respones is with new socket and the second with the socket used to recievd to ping.

    It seems that after the first SendTo, the socket only accept packet from the same address that was sent to..

    attached some of the code:

    CunstructL() {
    ss.Connect();
    iConn.Open(ss);
    iConn.Start();
    sock.Open(ss, KAfInet, KSockDatagram, KProtocolInetUdp, iConn);

    sockAddr.SetAddress(KInetAddrAny);
    sockAddr.SetPort(0);
    sock.Bind(sockAddr);

    iCSocketSender = CSocketSender::NewL(&sock);
    iCSocketLisetner->StartL(&sock, iCSIPClient);
    }

    void CSocketLisetner::StartL(RSocket *i_sock, MUDPReaderCallback *aMReaderCallback) {
    if(iState == 0) {
    sock = i_sock;
    anAddr.SetAddress(0);
    anAddr.SetPort(0);
    sock->RecvFrom(buf, anAddr, 0, iStatus);
    iState = 1;
    iMReaderCallback = aMReaderCallback;
    SetActive(); // Tell scheduler a request is active
    }
    }

    void CSocketLisetner::RunL()
    {
    if(iMReaderCallback)
    iMReaderCallback->GotUDPBuffer(buf, anAddr.Address(), anAddr.Port());

    anAddr.SetAddress(0);
    anAddr.SetPort(0);

    sock->RecvFrom(buf, anAddr, 0, iStatus);
    SetActive(); // Tell scheduler a request is active
    }

    void CSocketSender::SendMsg(TDes8 &bufToSend, TInt32 IP, TInt16 Port, MSocketDoneSend *aCallBack) {

    if(iState == 0) {
    sockAddr.SetAddress(IP);
    sockAddr.SetPort(Port);
    sock->SendTo(bufToSend,sockAddr, 0,iStatus);
    iState = 1;
    iCallBack = aCallBack;
    SetActive();
    }
    }

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

    Re: UDP/STUN Problem

    Do you actually know what happens if you bind to port 0? You could consider experimenting with a pre-defined constant port first.

  7. #7
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    102

    Re: UDP/STUN Problem

    I have the same problem with other non-zero Port.
    when using zero it generate random port and use it.

  8. #8
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: UDP/STUN Problem

    Quote Originally Posted by nire123 View Post
    I have the same problem with other non-zero Port.
    Do you send data to that port?
    when using zero it generate random port and use it.
    Note that there are no traces of getting that port in the code fragments you have posted.

  9. #9
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    102

    Re: UDP/STUN Problem

    the server side also uses recvfrom (PC)
    and send the replay to DESTINATION ADDRESS that is the same as the SOURCE ADDRESS of the incomming massege.

    the problem is at the symbian side, that it seems that if I send the first packet, with DESTINATION PORT X, it only recieve packet with the same SOURCE PORT.

Similar Threads

  1. Problem with eglSwapBuffers and heap corruption
    By greatape in forum Symbian Media (Closed)
    Replies: 2
    Last Post: 2007-05-24, 03:35
  2. netcards - Problem with opening adapter
    By kernj in forum Symbian Tools & SDKs
    Replies: 5
    Last Post: 2007-01-10, 08:56
  3. WAP service problem on Apache
    By bigg_o in forum Browsing and Mark-ups
    Replies: 3
    Last Post: 2005-04-17, 16:05
  4. Problem: S60 SDK for CW in PC with .NET
    By anttij in forum Carbide.c++ IDE and plug-ins (Closed)
    Replies: 1
    Last Post: 2005-02-28, 11:36

Posting Permissions

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