Read-only archive of the All About Symbian forum (2001–2013) · About this archive

http download via gprs and RSocket

0 replies · 2,652 views · Started 20 December 2004

Hello

Do you have any example code for using a GPRS connection to the internet?

What I'm trying to do is to download a file via http and gprs from a certain server. Unfortunately I cannot use the HttpRequest API because I'm using a Nokia 7650 which is compatible only with SDK 1.2 (OS ver 6.1) and it's not supported.

I'd like to do this using RSocket ,the TCP/IP protocol and HTTP commands but I'm new Symbian communications programming and I can't seem to be able to connect ot the server and send it some data.

I've found a sample for using sockets and tcp/udp connections for the Nokia 9210 (series 80) but it doesn't work for me.

I've created a small server that listens on port 4500 and used it to test this. The server works great but my client here does not.

Here is the code I used to try to connect (the client).
Any help is appreciated. Thanks

trh() and tr() are trace functions I use for debugging

int TestConnection::ConnectL()
{
//4294967260 ffff.ffdc -36 KErrDisconnected
//4294967267 ffff.ffe3 -29 KErrCommsLineFail
TInetAddr iAddress;
RSocket iSocket;
RSocketServ iSocketServ;
TRequestStatus iStatus;

// Open channel to Socket Server
User::LeaveIfError(iSocketServ.Connect());
// Open a TCP socket
User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockStream, KProtocolInetTcp));
// Connect to an Echo Socket by IP address
iAddress.SetPort(4500);
// iAddress.SetAddress(0x50606872); //address 80.96.104.114
TUint32 KInetAddr = INET_ADDR(80,96,104,114);
iAddress.SetAddress(KInetAddr); //address 80.96.104.114
iSocket.Connect(iAddress, iStatus);
User::WaitForRequest(iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
iSocket.Send(_L8("COMMAND FROM PHONE 111"😉,0,iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
User::WaitForRequest(iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
iSocket.Send(_L8("COMMAND FROM PHONE 222"😉,0,iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
User::WaitForRequest(iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
TBuf8<255> buf;
iSocket.Recv(buf,0,iStatus);
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
User::WaitForRequest(iStatus);
tr("data receveid:"😉;tr(buf.PtrZ());
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
iSocket.Close();
trh("istatus",iStatus.Int()); //0x80000001 - KRequestPending
iSocketServ.Close();

return 0;
}