Sockets api does not report error status

Login to reply to this topic.
Thu, 2005-02-17 18:47
Joined: 2004-10-21
Forum posts: 10
Hi guys, I got a strange problem and need help urgently. I've got a modified version of the sockets example working and I can connect OK to my test echo server.  However, when I kill the server and try to connect to it with my client, I don't get an error inthe iStatus reply.  Worst still if I try to connect to a port that is not opened, I still don't get an error, the app seems to connect OK??
I'm using the Rconnection class, Rsocket, TCP protocol and my vodafone internet as my IAP : Also I seem to be able to connect to just about anything!!! Help

Thu, 2005-02-17 23:44
Joined: 2003-12-30
Forum posts: 93
Sockets api does not report error status
Hi,

Here are my propositions to solve your problem :

You seem to have the same problem like me on Orange FR. I think some ports are blocked (110,80,8666 are opened) and you have always the same ip ? Try to open through your wap browsers a page that will give you your mobile phone ip ( i've made one for me, you can test it if you want : http://matdonline.free.fr/ip.php

On Orange FR (prepaid cards), I always have the same IP Address, but not on TMobile DE (not a prepaid card).

Other question : are you receiving with java ? or with another phone ?
If you are receiving in Java, try to receive byte arrays or make a test under C-Shell to see if packets are incoming. The other problem could be linked to your PC net configuration ( I assume that you are sending or receiving through PC). Have you checked that port 80 is free ( no running Apache) ?

I propose this code source to connect and then to receive data from a connected socket :

Code:
void MySocketEngine::InitSockets()
{
// Need to use two sockets - one to listen for
   // an incoming connection.
TInt err;    
iSession.Connect();
err = iListen.Open(iSession, KAfInet,
                           KSockStream, KUndefinedProtocol);

User::LeaveIfError(err);
   

// The second (blank) socket is required to
   // build the connection & transfer data.
   err = iSocket.Open(iSession);

   User::LeaveIfError(err);

 // Bind the listening socket to the required
         // port.
         TInetAddr anyAddrOnPort(KInetAddrAny, 80);
         iListen.Bind(anyAddrOnPort);


}

void MySocketEngine::StartEngineL(void)
{
 // Listen for incoming connections...
         iListen.Listen(1);
         iListen.Accept(iSocket, iStatus);
         SetActive();

}

TBuf8<1024> MySocketEngine::ShowBufferContent()
{
return iBuffer;
}

void MySocketEngine::RunL(void)
{
     if (iStatus==KErrNone)
     {
IssueRead(iBuffer);
  }
 
}

void MySocketEngine::IssueRead(TDes8& rcv_buffer)
{
   // Initiate a new read from socket into iBuffer
   __ASSERT_ALWAYS(!IsActive(), User::Panic(KPanicSocketsEngineRead, ESocketsBadState));
   iSocket.RecvOneOrMore(rcv_buffer,0,iStatus,iLen);

// Analyses the data
HBufC* txt = HBufC::NewL(1024);
txt->Des().Copy(rcv_buffer);
iDataReceiver->AnalyseMessage(txt->Des());
SetActive();
}

Be also careful to set the right size for the buffer !

Tell me if it helped !

MatD

Fri, 2005-02-18 11:39
Joined: 2004-10-21
Forum posts: 10
Sockets api does not report error status
Thanks matd, Is sill need some help.  My code is a client connection running on a nokia 6630 and the server some hacked together java echo server I wrote running on a pc. My client application connects OK to the server and I can send data back and forth OK. But when I shut it down my client application still  appears to"connect" to the server. Even when I try to connect to ports I have not opened on the PC, my client application still "connects".  Is there something wrong with the symbian API ?  I have also tried :

TNifProgress aProgress;
iRConn.Progress(aProgress);

The progress info is not conclusive either.

Yes I always have the same IP address when i sucesfully connect, however it is different from number I got from your browser app.  When I connect, I get 194.182.124.185, but when i tried your wap browseer app i got 194.182.124.163.  What is the significance of this. Also what is the significance of the blocked ports you mentioned in your answer.  Help Smiley
Fri, 2005-02-18 13:48
Joined: 2004-09-27
Forum posts: 1
Sockets api does not report error status
I suppose you get timeut at least, right?

I suppose it's a matter of timeout. Connect() take some time before can return an error.

I had similar situation with Java and Blackberry. Had to wait before device returns timeot.

Regards.
Wojtek
Fri, 2005-02-18 16:03
Joined: 2003-12-30
Forum posts: 93
Sockets api does not report error status
Hi !

I have some questions :

When you say it appears to connect on your PC can you see the opened port + Ip address of your mobile phone ?
I don't want to tell things that are wrong, but I have a hesitation on Java communicating with Symbian C++ through sockets. Can you try on your Java side to receive the stream as a byte stream ? Perhaps ( i really say perhaps because it's just a supposition), java hasn't completely received the whole message, and then that the Symbian side thinks that the socket is still connected. I had a Java/Symbian C++ problem but in the other direction http://forum.newlc.com/viewtopic.php?t=5562
 
Do you have the possibility to write a server echo Client in another language (Python or C-Shell) ?

The timeout only occurs if there's no listening/opened port on the other side with the Socket Example I guess.

For the same IP, it could mean that you are not directly connected to the mobile phone, but to the server between the mobile phone and the internet ( kind of gateway). For the blocked ports : the operators are blocking not used ports to avoid intrusions ( i read it on the Orange Partner Forum), so some ports like 110, 80 are left opened.
If you are connected take the ip address you have in your wap/webbrowser.

Hope it'll help !

MatD

Fri, 2005-02-18 17:58
Joined: 2004-10-21
Forum posts: 10
Sockets api does not report error status
Thanks Wiktorn, matd,

I think I'm beginning to get the picture, I don't seem to be able to get an immediate error on the connect.  Do I have control on the time?
Also with regards to the gateway theory, matd, with a tcp connection over vodafone internet IAP, is the tcp connection to the gateway or does the gateway provide a bridge to the computer I'm trying to connect to.  I'm fairly new to this TCP/IP programming idiom, Help, because I thought it was more of a point to point connection between (initated from my phone) to my PC  echo server over the internet.   So if the port does not exist, it should give an error.  Maybe the symbian implementation is lacking in the respect.  Help Smiley
Fri, 2005-02-18 18:30
Joined: 2003-12-30
Forum posts: 93
Sockets api does not report error status
Hi !
Quote
Also with regards to the gateway theory, matd, with a tcp connection over vodafone internet IAP, is the tcp connection to the gateway or does the gateway provide a bridge to the computer I'm trying to connect to.

I'm not 100 % sure but this "gateway" should look like :

Mobile Phone <--proxy-><-Gateway-><-----Internet ---><-a firewall->your PC
                           


Which port are you using on your PC ? If you set 80 on your mobile phone, it means that you are connected to an existing IP. Do you have Apache server running ? Or a firewall ?
 
You will only get an TimeOut error if the port is not opened or unavailable. But after having read your posts, it's not a gateway problem, because you are trying to send datas from the mobile phone to the pc

Could you post a code snippet of your code in order to see what could be wrong ? But to be quite frank, i'm pretty sure, that something might be wrong on your java side. I had the same problem and so that Python could receive my message I've sent with the mobile phone.  Roll Eyes

Tell me if it worked !

MatD

Tue, 2005-02-22 11:02
Joined: 2004-10-21
Forum posts: 10
Sockets api does not report error status
Thanks matd,

I was dragged off to do other stuff... Yeah, thanks for the advice, I think, my problems were two fold, one, the java side echo server was still opening ports even when it was down.. I don't know how, but it was!! just as you hinted. The second thing is that the symbian api ( Connect()) does not issue a disconnect if there are no ports opened, just as Wiktorn sugested, but times out .  I think the iStatus variable only reports that the api ( or connect operation was started succesfully in the lower level) but not the result of the connection.   Thanks again guys for your help, and thanks matd for the diagram, there were very useful.
Fri, 2005-04-29 11:12
Joined: 2005-04-13
Forum posts: 24
Sockets api does not report error status
Hi guys,

I'm having the exact same problem. I'm running a java server that runs on port 5222 hosted on one of my servers (Linux box). My problem is with the connection itself... it ALWAYS times out. I'm not that familiar with symbian yet so please forgive me if I dont immeadiately understand what you discuss. Please help me. I want to create a C/C++ server but its gonna take time so any help in bridging the java/symbian gap would be soooooo appreciated.

Thanx.
Fri, 2005-04-29 13:03
Joined: 2004-10-21
Forum posts: 10
Sockets api does not report error status
Is it he server or client side connection that times out ?
Tue, 2005-05-03 11:02
Joined: 2005-04-13
Forum posts: 24
Sockets api does not report error status
Its the client side that times out. The server never actually sees the client connect.
Tue, 2005-05-03 13:56
Joined: 2004-10-21
Forum posts: 10
Sockets api does not report error status
The symbian/Series60 sockets api does not inform yur application if it can't connect to a server, it times out instead if you don't have a connection.  As a first attempt, try increasing the length of the timer, maybe your app takes slightly longer than yur timer permits to establish a connection.  Also do you have an internet enabled phone with an IAP? Try writing a java client for yur server to see if it connects. It could be that the server may not be opening ports etc..  I don't think it matters that the server is written in java and sitting on a unix box.  I believe the underlying TCP/IP sockets implementations is independent of this.
Wed, 2005-05-04 07:40
Joined: 2005-04-13
Forum posts: 24
Sockets api does not report error status
Hi,

I agree with you about that part. I think it has more to do with the network operator. I have another thread where didster told me that the network operator might be blocking the port.

Well, I also increased the timeout to 1.5 mins and it still times out. Also, if I connect to port 80, it immeadiately connects. I think it might be the network operator.

Thanx for the info tho.  Cheezy
Wed, 2005-05-04 09:58
Joined: 2005-05-03
Forum posts: 3
Sockets api does not report error status
Hi
I'm not sure that i found the same as you. I have ploblem when I try to connect to the network with client socket app, CActive wait for iStatus from outstanding request of iSocket.Connect(...)  function until time out.
But this problem occur with some network operator and I succeed connect the client socket with some network operator.
If your country have another network operator,let's try to change.
  • Login to reply to this topic.