views:

876

answers:

7

I've written a socket server which communicates with my actionscript 3 flash game using the Socket class. This is a TCP connection, which I thought would mean that it is 100% sure that the sending message will be received by the server as this is done low-level. So, if it would fail to send it would resend the message.

This does seem to be the case for me and for two other people I've tested my build with. However, with one person, sometimes (rare but not ignoreable) the message is not being received by the server even though this does not seem to happen for other people their systems. This person however never has any problems with other professional multiplayer games, which means that it must be an issue with my build.

Is there anything that I can do to make sure that the message is being send correctly, and am I wrong about TCP being 100% secure because messages are supposed to be resend on failure low-level?

+2  A: 

You can always play with tcpdump or wireshark to see what is going on on the wire. Event if your problem is not at the TCP/IP level, these are too useful network troubleshooting tools not to learn.

Nikolai N Fetissov
Thing is this is flash and thus I have no control over the socket interface. It should work properly but is not on rare occasions. There must be people who are known with this problem and know what may cause it.
Tom
A: 

Try to send messages (using your own protocol) to server from Person B with nc

If you can isolate the problem in client or server part of AS3 sockets, that would already be a major step.

Note: I used Actionscript3 sockets successfully on a project a few months back, only slightly tricky part was setting up the domain policy server properly.

A crazy idea: maybe recompile kernel with this option? Network packet drop alerting service (NET_DROP_MONITOR) Disclaimer: I have never tried this..

Sint
Unfortunatey I do not have access to person B's computer. Again I do not see how this should be a problem on person B's side as this person is able to use any other UDP dependent application just fine (such as multiplayer games). I will post some actionscript code when I am at the required location.
Tom
UDP and TCP are very different animals. Which are you actually using?
Heath Hunnicutt
A: 

Hmm, I have done few socket applications and never get problems like yours. Other problems yes but not with disappearing messages. Can you give as more information about messages failed to send? (message size, send frequency, etc.)

Konrad
+1  A: 

You are correct in your understanding of TCP, kind of. TCP provides a data stream to your application that you can write data to and it will arrive and arrive in order. That is, or course, assuming the connection doesn't die, which it can. I would suggest using a program like wireshark as Nikolai suggested to identify that the correct information is, in fact, being sent and to the proper address. I would then utilize wireshark on the server to assert the same things. Are there any characteristics of the connection Person B has that are different from Person A or yourself? (wireless, etc.)

Chris Thompson
+4  A: 

You're right that this is a common problem, but the problem is a general one, independent of flash. I sent a message but it was never received, what should I do? You need to check that your client code really did send the message; you need to check that the message left the client machine; you need to check that the message reached the server machine; and you need to check that the server application received the message. You'll also want to make sure that your connection/socket between the client and the server is still alive.

In trying to diagnose this problem, assuming that TCP failed is the wrong place to start. If you're using UDP, then the story is different because UDP does not guarantee delivery (but you already knew that, right?).

Repeating previous suggestions, you should use Wireshark (or equivalent) to determine if the message leaves the client machine. You can start on your server, to make sure that nothing funny is happening there; however, if there is really no trace of the message on the server side, then you'll need to provide some kind of client-side instrumentation to see what's going on over there.

jdigital
I've investigated more and I _think_ (not 100% sure, as this might have been a different issue, or not) that the message is being send, and being received by the server but sometimes that player I talked about does not receive the update from the server on other clients. I have no idea what is causing this, it doesn't occur for me or someone else I tried with.
Tom
Upvote for narrowing the problem definition
Karthik
A: 

Do you check bytesAvailable?

Another question: does your message arrive in pieces to the troubled person, is your code prepared to handle those situations?

Alexander Farber
A: 

i am seeing the same issue with my socket implimentation. If the server sends to many messages to flash at once flash seems to drop messages. So, say the server sends 10 messages in immediate succession on the socket to flash, flash only sees the first 2 and drops the rest. However if we add just a 50 millisecond delay between sending messages flash has no problems reading all 10.

Is there a more reliable way to read the data from the stream then readUTFBytes() so we dont have to add a delay between messages?

Scott C
Also, i have verified with TCP-Reflector that all messages leave the server and are sent to flash and the messages are all properly formatted and correct.
Scott C
What does your code look like? How many bytes are in each message?
jdigital
You might be better off starting a new topic rather than appending to an existing topic.
jdigital