• Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket Programing using TCP Protocol  RSS feed

 
Thamaiyanthi Pitchaimuthu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Am developing the client application using Socket class(TCP Protocol), which will read the data packet continously from the Server socket which will have the header and payload. Header part will have message length length) using the same am reading the (in data packet 2 bytes for message remaning data) . the problem is here some times am getting the message length 65535.
Am in very big confusion why it is coming whether the problem in my application or in tcp connection. please i need your help to trouble shoot.

Thanks.
Thamaiyanthi.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post the complete error message and the code that's causing it, preferably an SSCCE of both client and server.
 
Thamaiyanthi Pitchaimuthu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Really Sorry for my mistake while editing the code i missed out) can you please check now . i use code only now..
Thanks..
Am developing only client application, am not aware of Server,
i will not get any exception stacktrace and all, while reading message length simply i will get Message length =65535 which is the maximam value of unsigned 16 bit.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume by "i will get Message length =65535" you mean that the "if (length == 65535) { ... }" block is executed? That's odd, since the "if (length == 0) { ... }" block before it should always be executed, seeing that the readMessage method always returns 0 (unless it throws an exception).

You should edit your post to UseCodeTags, by the way. Makes it much easier to read.
 
Thamaiyanthi Pitchaimuthu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response..

okay i will code tags,

No that message length always wont be 0, i would get like 139,201. so in some cases only i will get message length is 0 like socket closed.. my doublt is why am getting 65535, where the thing going wrong whether in my code or tcp connection.
this is going as a very big issue..
Thanks..
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I meant messageLength, not readMessage. While the "message length" may not always be 0, the result returned by the messageLength method will always be 0 - check its code. And please edit the post to use code tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!