Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Socket scenario missing data

 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have taken some socket examples and changed them to fit my needs. My code does everything correctly except some characters are missing. This is what it should be:
MSH|^~\&|BEMRX||PYXISRX||200701031628||^~\&^RDE||P|2.3|
this is what I get:
SH|^~\&|BEMRX||PYXISRX||200701031624||^~\&^RDE||P|2.3|
So it cuts off the first letter.
Here is my code
Client Code:

Server Code:


It has to be the infile.read() but how do I move the read back?

Thanks,
Tom
[ January 08, 2007: Message edited by: Tom Henricksen ]
 
Joe Ess
Bartender
Posts: 9319
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tom Henricksen:
It has to be the infile.read() but how do I move the read back?


Move the what back now?
infile.read() reads a single character, then the next line reads until EOL, so it is the cause of your problem. The correct way to read a line from a file would look like your server code:
 
Tom Henricksen
Author
Ranch Hand
Posts: 144
5
Eclipse IDE jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Joe
Even though your a bartender I owe you a virtual beer.

Tom
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic