block I/O and reliability
Posted on 2003-11-08
Hi, I use nio (buffers and channels) to transfer data over the network and was wondering if it is a totally reliable transfer (i.e. can data that sent using a channel get lost on the way?). In my chat program, which seem to work alright, sometimes when I send a long string message such as "I want to eat an ice cream" the server sends back a string "I want to eat an ice cream \n n ice cream". The last substring of the original message is sent along and after the original. This does not happen all the time though, for example if I send "Hello", it returns "Hello" and that hasn't failed yet. So I just wanted to know if this is possibly due to the nature of nio stuff and that I need to come up with a way to improve this communication protocol or because I encoded and decoded using "US-ASCII" and need to use other character set or if this is some logic error I made in my program. Any suggestions?