a socket problem
-
i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?
Someone ate a byte or two on the way? Seriously though, you need to be more specific than that. Read the guidelines ("How to get an answer to your question") which is on top of this forum, please.
It is a crappy thing, but it's life -^ Carlo Pallini
-
i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?
Inputs, outputs...We have no elements, Watson! :-D
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?
maybe there is something about network byte order!
-
maybe there is something about network byte order!
The network packets contain: - packet information, which must obey the byte order specified in the standards specification; the drivers and network protocols are there to take care of that on both ends. - the actual user-defined data (the "payload"); here it is up to the user how the bytes have to be interpreted. As the OP said it works often and fails sometimes, I don't think a byte ordering mistake was made. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
The network packets contain: - packet information, which must obey the byte order specified in the standards specification; the drivers and network protocols are there to take care of that on both ends. - the actual user-defined data (the "payload"); here it is up to the user how the bytes have to be interpreted. As the OP said it works often and fails sometimes, I don't think a byte ordering mistake was made. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
Please upload you code............
-
i wrote a c/s app. the client sends a DWORD to the server.it runs no error,but the DWORD sent doesn't equal to the DWORD received some times ,how it happens?
-
o!! I find the problem at last! It is a Multithread problem, one data struction used in multithread without protection, data was dirty. :)
a dirty DWORD??? you mean you didn't correctly make a local copy then, it is too small to not update atomically. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
-
a dirty DWORD??? you mean you didn't correctly make a local copy then, it is too small to not update atomically. :)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Show formatted code inside PRE tags, and give clear symptoms when describing a problem.