Problem in socket binding

Login to reply to this topic.
Mon, 2007-09-24 06:25
Joined: 2007-08-30
Forum posts: 20

hi all,

I am using socket to send sms to a particular port number. But I am getting socket not binding error.

//Opening socket
User::LeaveIfError(
socket.Open(sockServ, KSMSAddrFamily, KSockDatagram, KSMSDatagramProtocol));
CAknInformationNote* informationNote = new ( ELeave )CAknInformationNote;

TSmsAddr smsaddr;
smsaddr.SetSmsAddrFamily(ESmsAddrSendOnly);
smsaddr.SetPort( 16500 );

//binding socket with Sms address

TInt bindStatus = socket.Bind(smsaddr);
if (bindStatus = KErrNone)
{
informationNote->ExecuteLD(_L("Binding Success"));
//code to send sms
}

else
{
informationNote->ExecuteLD(_L("Binding Un Success"));
}

//end

Every time I am getting the "Binding Un Success" as display...
what is wrong with my code..

Please help me guys..



Thanks & Regards

Kannabiran.K


Mon, 2007-09-24 09:40
Joined: 2007-08-30
Forum posts: 20
Re: Problem in socket binding


I am using socket to send Sms to a port...

I want to know what are all the capabilities needed to send SMS to a port using socket?



Thanks & Regards

Kannabiran.K

Mon, 2007-09-24 11:41
Joined: 2004-11-29
Forum posts: 1246
Re: Problem in socket binding

This line:

if (bindStatus = KErrNone)

needs to be:

if (bindStatus == KErrNone)

An easy mistake to do.
One way to prevent it from happening is to always write the constant to the left like this:

if (KErrNone == bindStatus)

If you get used to write it like this, you will get a compile time error if you happen to write only "=" by mistake.

Mon, 2007-09-24 13:01
Joined: 2007-08-30
Forum posts: 20
Re: Problem in socket binding


I tried with that.. Then also not working..
My problem is the SMS is receiving to the inbox... I want to receive it in a specific port(16500) from my J2Me application.

which one is correct method to specify the to address?

// I am using this
smsMsg->SetToFromAddressL(_L("sms://+919841240330:"));

smsMsg->SetToFromAddressL(_L("9841240330"));



Thanks & Regards

Kannabiran.K

  • Login to reply to this topic.