Help In HTTP via RSocket

Login to reply to this topic.
Wed, 2007-07-25 08:36
Joined: 2006-11-22
Forum posts: 73

Hi to All,
I want to access a web page and its database from my symbian client with RSocket for connection with my server i write a code but it fails on socket connect method, Please tell me what is wrong over there,

///Code For HTTP;

TUriParser url;
RSocket sockfd;
RSocketServ sess;
RHostResolver iHostResolver;
TNameEntry iNameEntry;
TNameRecord iNameRecord;
TInt err;
_LIT(KMyServer, "http://72.156.123.253:7001/weblogic6/filechek1");

User::LeaveIfError(sess.Connect());
url.Parse(KMyServer);
User::LeaveIfError(sockfd.Open(sess,KAfInet,KSockStream, KProtocolInetTcp));
if (url.Extract(EUriScheme).Compare(_L("http")) != 0)
{
// Invalid URL - didn't start with "HTTP://"
User::Leave(KErrArgument) ;
}
err = iHostResolver.Open(sess,KAfInet,KProtocolInetTcp);
User::LeaveIfError(err);
iHostResolver.Close();
iMyresolveServ.Copy(url.Extract(EUriHost));
TRequestStatus iStatus;
iHostResolver.GetByName(KMyServer, iNameEntry, iStatus);
TInetAddr address ;
address = iNameEntry().iAddr;
address.SetPort (80) ;
sockfd.Connect(address, iStatus);// fails here

sockfd.Close();
sess.Close();

Also I m interested to access authenticated pages with user name and passward. please tell me how can i do this it will be a great help.

Thanks in Advance


Wed, 2007-07-25 11:54
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: Help In HTTP via RSocket

I would recommend you to use an ActiveObject (AO) in your case. Or at least a User::WaitForRequest() (but that is not always preferable). Check any of the socket help on SDK, or search in this forum or FN.Wiki/DIBO for the implementations/tutorials.


Wed, 2007-07-25 14:28
Joined: 2006-11-22
Forum posts: 73
Re: Help In HTTP via RSocket

i tried WaitForRequest() after GetByName() but it is going crash on WaitForRequest
please tell me the solution how i could achieve this

thanks

Wed, 2007-07-25 23:11
Joined: 2006-09-18
Forum posts: 68
Re: Help In HTTP via RSocket

I also think you need to use an Acrive Object (AO). During the setup of the connection control has to be taken away from your code, and other active objects need to be sheduled, which cannot happen when you use something like WaitForRequest(), I might be confusing it with establishing a secure connection. So you can change to an AO as last resort.

I see you call iHostResolver.Close(), before calling iHostResolver.GetByName(KMyServer, iNameEntry, iStatus), you cannot call this on when it is closed, think of iHostResolver as a file, it must be open to read.

_LIT(KMyServer, "http://72.156.123.253:7001/weblogic6/filechek1"); gives an ip address "72.156.123.253" you don't need a dns lookup, it specifies a port "7001" which you overide/ don't use with address.SetPort (80) .
Try code below.

TRequestStatus iStatus;
err = iHostResolver.Open(sess,KAfInet,KProtocolInetTcp);
User::LeaveIfError(err);
iMyresolveServ.Copy(url.Extract(EUriHost));
TInetAddr address ;
err = address.Input(iMyresolveServ);
if( err != KErrNone )  // something other than an ip adress, a dns name maybe? (www.example.com)
{
    iHostResolver.GetByName(iMyresolveServ,iNameEntry,iStatus) ; //do a dns lookup, get ip address
    User::WaitForRequest(iStatus);
    User::LeaveIfError(iStatus); // leave if the name coudn't be resolved
    address = TInetAddr(iNameEntry().iAddr);
}
else // we have a valid IP address (ex. 72.156.123.253)
{
    iHostResolver.GetByAddress(address,iNameEntry,iStatus) ; //do a reverse dns lookup, not really necesary
    User::WaitForRequest(iStatus);
}
iHostResolver.Close();

address.SetPort (7001) ;
sockfd.Connect(address, iStatus);
User::WaitForRequest(iStatus);

Thu, 2007-07-26 08:06
Joined: 2006-11-22
Forum posts: 73
Re: Help In HTTP via RSocket

Ok Sir
I got your point if i use only 72.156.123.253 and port 7001 it works properly .
But my motive is other i want to access a jsp page from this that take a user name and password that is the reason i was using "http://72.156.123.253:7001/weblogic6/filechek1".

Please tell me how can i access this,
Thanks to all of u for your favorable reply

Thu, 2007-07-26 21:52
Joined: 2006-09-18
Forum posts: 68
Re: Help In HTTP via RSocket

Once connected to the server you make a HTTP GET request with the path "weblogic6/filechek1". There is an HTTP API as well as a webbrowser API, which should make things easy, but I have never used them.

Maybe someone else can help you out with that.

Good luck!

Fri, 2007-07-27 13:01
Joined: 2006-11-22
Forum posts: 73
Re: Help In HTTP via RSocket

Hi Werries
I will do the same as u suggested and get back the result...........
Thanks

Fri, 2007-08-10 14:37
Joined: 2006-11-22
Forum posts: 73
Re: Help In HTTP via RSocket

Hello Sir,
I am not getting the solution please tell me how can i send a user name and password .

Thanks

Fri, 2007-08-17 09:55
Joined: 2006-09-18
Forum posts: 68
Re: Help In HTTP via RSocket

Don't know if this will be of use but take a look at Symbian_OS_End-to-End_Sockets_API_Example_v1_3_en
and Symbian_OS_End-to-End_HTTP_API_Example_v1_3_en
at Forum Nokia

Thu, 2007-08-30 14:25
Joined: 2006-11-22
Forum posts: 73
Re: Help In HTTP via RSocket

Hi to All,
Finally i have developed a symbian client and a web based servlet and i can connect my client to servlet via RSocket Connection but have another issue. I need to send a string from my client to servlet and I dont know how to send this. this time i m using
_LIT8(KDataToWrite,"GET /TimeProject/trylogin HTTP/1.0\xD\xA\xD\xA");
sockfd.Write(KDataToWrite,iStatus);
To connect with my servlet but if i want to send a string on this servlet like "hello" what should i do .
Please tell me how can i do this

Thanks in advance.

  • Login to reply to this topic.