|
|
User login
Feeds |
Correct way to close RSocket
|
|||||
| Tue, 2004-11-09 19:26 | |
|
Hi
What is the correct way to close an RSocket. I am using this code: Code: iSocket.CancelAll(); TRequestStatus iThisStatus; iSocket.Shutdown(RSocket::ENormal, iThisStatus); User::WaitForRequest(iThisStatus); iSocket.Close(); This code works no errors nothing. But when i try to Open, Connect the same socket again after that i cannot read any data from it. Recv call blocks forever. (Send works) Any Idea what this could be? |
|
Forum posts: 1379
didster
Forum posts: 64
Will try that.
I just tried to find out what is going on with Ethereal (network sniffer).
I can see:
- First Connection Open, Send HTTP GET
- Receive Webpage
- Second Connection Open, Send HTTP GET
Now the webserver sends the webpage correctly until the buffer of the emulator is full, after that just TCP ZeroWindow Packets. Which is the correct behavior.
Its correct because i can Recv/Read as much as i wan't from that socket the read method never completes(so the network buffer never gets emptied).
I guess i'll have to try that on the device itself and it is only a emulator bug.
I also tried to completly destroy the RSocket, disconnect the RSocketServer and recreate both no luck. Exactly the same problem.
Forum posts: 1379
Unless you are trying to rebind a listening socket to the same port. In which case there will be a small delay while the socket is "really" closed before you can rebind to that same port (unless you set reuse address IOCTRL anyway).
How are you connecting your emulator to the "net" as such? (i.e. Eithernet plugin, PERNSOCK, mRouter etc etc) It may be a hang up from that.
didster
Forum posts: 64
Forum posts: 1379
It may be something to do with that then. Try it on the phone - but calling .Close() should be enough.
didster
If your buffer is larger than the web servers reply, you will never see it, because event (2) loses the less than full buffer.
If you use HTTP 1.1, server doesn't close the socket, so your receive will hang forever (or until server times out anyway).
[The problem description doesn't sound like this is the problem, but thought to mention just in case -- anyway, always use RecvOneMore].
Forum posts: 64
My Server is a php script which sends 50MB of A-Z Characters. (It's for a gprs performance test app).
So i have a AO that Cancels the recv and Closes the socket after a specific time.
So i have a AO that Cancels the recv and Closes the socket after a specific time.
Hmm... does your php script stop at this point, or does it just keep sending to the already closed socket?
Perhaps, use two sockets and connect to your server twice, to see that it can handle multiple activations of the same php script?
Forum posts: 64
First download works fine.
Second download i cannot receive any data on the device or emulator.
Using a packetsniffer i see that my server is sending out the data until the device sends a ZeroWindow packet back which says that the devices network buffer is full and cannot handle more data at this point.
However the data in the network buffer isn't passed up to my socket for some reason.
Forum posts: 64
Double-Checked that a few times
I also have two incoming GET requests on my server log.
If i try the same thing using normal browser it works. So its not some bug in the php script that sends the data.
Even if i close the connection using RSocket::Close or RSocket::Shutdown and Close. The device never sends out the correct TCP FIN packets to close the connection
Forum posts: 64
tried delete'ing and creating a new RSocket object. Same Thing.
So my conclusions:
If the socket closed with a EoF i can create a new socket that works. (Because there was a nice FIN, FIN ACK)
If i abort the transfer in a socket i can't create a new socket or re-connect the same sockets again.
This is really starting to make me angry
If you wish to send me sample ethernet capture logs and stack logs, contact me via link at the bottom of the web page
http://www.funet.fi/pub/sci/bio/life/
Forum posts: 64
And i think it is because of my Active Object. (strange that the recv hangs tho)
First Download gets canceled with another timer active object and I restart the second download in the DoCancel method(over another event handler which gets called from the DoCancel method).
At that point my download active object still reports as active.
But the captured network traffic is still a bit strange.
..you cannot re-activate the AO in DoCancel. After DoCancel AO is inactive, and DoCancel must make sure that no asynchronous events are coming to the iStatus any more (thus, DoCancel cancels the operations on the socket).