Sockets api does not report error status
| Thu, 2005-02-17 18:47 | |
|
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 |
|






Forum posts: 93
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 :
{
// 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
Forum posts: 10
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
Forum posts: 1
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
Forum posts: 93
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
Forum posts: 10
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
Forum posts: 93
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.
Tell me if it worked !
MatD
Forum posts: 10
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.
Forum posts: 24
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.
Forum posts: 10
Forum posts: 24
Forum posts: 10
Forum posts: 24
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.
Forum posts: 3
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.