Problem regarding binding of Socket..

Login to reply to this topic.
Tue, 2006-04-25 12:55
Joined: 2006-04-08
Forum posts: 41
hi
my code is not being able to bind socket, neither my code is leaving anywhere.
i am giving my piece of code, if anybody can suggest that what could be possible reasons to this problem....

i want to make clear that i am running this code on emultor n i have issued Open(socketserversession,KAfInet,KSockDatagram,KUnspecified); prior to CSocket::Bind() without any RConnection instance.
N also iSocket is member variable of CSocket class.

TInt CSocket::Bind(TUint aLocalPort)
{
   TInetAddr anAddr(aLocalPort);
   const TUint32 KInetAddr = INET_ADDR(127,0,0,1);
   anAddr.SetAddress(KInetAddr);
   User::LeaveIfError(iSocket.Bind(anAddr));

   TInetAddr addr;

   iSocket.LocalName(addr);
             //At this point i am checking whether socket is binded to correct address or not.           

   if(! addr.Match(anAddr))
   {
             //control of the program is getting inside this if statement.
             }   

   iStateOfSocket=ESocketBinded;//Socket state changed.
   return 1;
}

Tue, 2006-04-25 20:36
Joined: 2005-02-18
Forum posts: 100
Re: Problem regarding binding of Socket..
It should work with the real RSocket library.

Are you possibliy using some replacement library like (prnsock.lib or something).
Wed, 2006-04-26 05:30
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding binding of Socket..
Quote from: msa2
It should work with the real RSocket library.

Are you possibliy using some replacement library like (prnsock.lib or something).
No, i am not using any other library.
iSocket member variable in my class is the instance RSocket class which is linked against esock.lib in the mmp file.

Amit.
Wed, 2006-04-26 07:44
Joined: 2006-04-08
Forum posts: 41
Re: Problem regarding binding of Socket..
I have solved the problem with help from somebody, actually i in the Open() i was not specifying protocol family as 'KProtocolInetUdp', i was specifying          'KProtocolUndefined'.

Amit.
  • Login to reply to this topic.