File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Socket scenario missing data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Socket scenario missing data" Watch "Socket scenario missing data" New topic
Author

Socket scenario missing data

Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

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

Joined: Oct 29, 2001
Posts: 8836
    
    7

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:


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Tom Henricksen
Ranch Hand

Joined: Mar 23, 2004
Posts: 136

Thanks Joe
Even though your a bartender I owe you a virtual beer.

Tom
 
 
subject: Socket scenario missing data
 
Similar Threads
Socket : MultiClient Server
Reading a binary file from a client to server
sockets and printwriting
two server and many client....
not able to connect...