Hi
I am sending a data from the mobile phone to a server using UDP. The application works fine when im using the emulator. The server is on a public IP in another machine. And the application is on my emulator. This setup works fine. Now problem comes when I load the application on to a real mobile phone. Here the application sends the message. I know this because I can see the GPRS symbol. But the server does not receive the message.
Please help. The device is Nokia 6680. I am sending a simple "a" character to the server. I am sending it only once. I have tried sending it more than once also but it doesnt resolve the problem. Here is the code:
Code:/* CEchoEngine: main engine class for connection and shutdown */ CTcpEngine::CTcpEngine() : iStop(ETrue), CActive(EPriorityStandard) { } CTcpEngine* CTcpEngine::NewL() { CTcpEngine* self = NewLC(); CleanupStack::Pop(); return self; } CTcpEngine* CTcpEngine::NewLC() { CTcpEngine* self = new(ELeave) CTcpEngine; CleanupStack::PushL(self); self->ConstructL(); return self; } /* Constructs object, and opens a socket */ void CTcpEngine::ConstructL() { iEngineStatus = EComplete; CActiveScheduler::Add(this); // Open channel to Socket Server User::LeaveIfError(iSocketServ.Connect()); // Open a TCP socket User::LeaveIfError(iEchoSocket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp)); TSockAddr addr; addr.SetPort(1111); TInt errcode = iEchoSocket.Bind(addr); ConnectL(INET_ADDR(xxx,xx,xxx,xxx)); } void CTcpEngine::DoCancel() // Cancel asychronous requests { // Cancel appropriate request to socket switch (iEngineStatus) { case EConnecting: iEchoSocket.CancelConnect(); break; default:; } } /* Connect to an Echo Socket by IP address */ void CTcpEngine::ConnectL(TUint32 aAddr) { // port number for test purposes - may need to be changed iAddress.SetPort(4044); iAddress.SetAddress(aAddr); iEchoSocket.Connect(iAddress, iStatus); iEngineStatus = EConnecting; SetActive(); } /* Exported function wrapping call to CEchoWrite: writes character to socket */ void CTcpEngine::Write(TChar aChar) { /* In this simple implementation, if iEchoWrite is already active, ignore call. Full implementation would buffer data */ if (iEngineStatus == EConnected) IssueWrite(aChar); } /* Exported function wrapping call to CEchoRead: reads character from socket */ void CTcpEngine::Read() { if (iEngineStatus == EConnected) IssueRead(); } /* Active object request complete handler. iEngineStatus flags what request was made, so its completion can be handled appropriately */ void CTcpEngine::RunL() { // Cancel TimeOut timer before completion _LIT(KConnecting,"\n<CTcpEngine> Connecting\n"); _LIT(KConnectionFailed,"\n<CTcpEngine> Connection failed"); _LIT(KDNSFailed,"\n<CTcpEngine> DNS lookup failed"); _LIT(KTimedOut,"\n<CTcpEngine> Timed out\n"); _LIT(KDomainName,"\nDomain name = "); _LIT(KIPAddress,"\nIP address = "); TBuf<15> ipAddr; switch(iEngineStatus) { case EConnecting: // IP connection request if (iStatus == KErrNone) // Connection completed sucessfully { //iEngineStatus = EConnected; iBuffer.SetLength(0); iBuffer.Append('a'); iEchoSocket.SendTo(iBuffer,iAddress,NULL,iStatus); SetActive(); } else { iEngineStatus = EConnectFailed; } break; case EConnected: break; default:; }; } CTcpEngine::~CTcpEngine() { iEchoSocket.Close(); iSocketServ.Close(); } /* Shutdown connection request */ void CTcpEngine::Stop() { _LIT(KETerminate,"\n<CTcpEngine> Terminating\n"); switch (iEngineStatus) { case EConnected: // Stop live connection case EConnecting: // if request to CTcpEngine, then stop it Cancel(); break; default:; } } /* Read data from a stream socket */ void CTcpEngine::IssueRead() { //iEchoSocket.Recv(readBuf, 0, iStatus); iEchoSocket.RecvFrom(readBuf, anAddr, 0, iStatus); SetActive(); } /* Write data to a stream socket */ void CTcpEngine::IssueWrite(const TChar &aChar) { // Set up buffer iBuffer.SetLength(0); iBuffer.Append(aChar); iEchoSocket.Write(iBuffer, iStatus); SetActive(); };
Thanks in advance!



