-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gen.TcpHandle Question #152
Comments
If I do understand your question correctly... The main reason for returning |
i get it |
not sure if I follow your example. could you please share your HandlePacket code and what you expected to see |
func (this *handle) HandlePacket(process *gen.TCPHandlerProcess, packet []byte, conn *gen.TCPConnection) (int, int, gen.TCPHandlerStatus) { I think when packet is not enough(8byte), I will wait next call At this point, I can get the complete data. But it not,it have next data but first data is lose |
e.g I send divided into two this slice 3 seconds at intervals code: I know that returning a "packet too short" error on the first call But on the second call, you must receive the complete data after being sent twice. It is -> [3 217 0 0 26 0 0 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90] but I receive [26 0 0 0 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90] I lose [3 217 0 0] That is the data sent for the first time. |
You lose the first 4 bytes because of a timeout of socket reading which is 3 seconds by default. To see that, you can add a method HandleTimeout to your object I'm thinking of fixing it by keeping the data in the buffer even timeout is happening. |
Thank you. but I have a new question |
done in v2.2.3 |
When I find that the incoming packet length of Calling HandlePacket is less than the value I want,I will return the value of left as len (packet), but why is the packet information not received last time overwritten when I receive the next package?
The text was updated successfully, but these errors were encountered: