wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Parsing text from a TCP/IP socket. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Parsing text from a TCP/IP socket." Watch "Parsing text from a TCP/IP socket." New topic
Author

Parsing text from a TCP/IP socket.

Brian Tomlin
Ranch Hand

Joined: Dec 06, 2000
Posts: 31
Can anyone suggest the best way to parse text from a socket?
I have a listener (server) that opens a socket and a client that connects to that socket on the server and sends data. I need to be able to parse this data and send a response back to the client.
The data to be parsed is sent in blocks of text identified with a start block of ASCII <VT> and an end block character of ASCII <FS>.
The first thing I need to do is look for the start block. If it does not exist, I will return and error string to the client. If it does, I will continue to read until I get to the end block. When I have the full string, I will file it in a RandomAccessFile and parse the string accordingly.
I am currently using a BufferedReader and the readLine method, but I'm not sure how to check for these start and end block characters.
Any suggestions would be greatly appreciated.
Brian
Brian Tomlin
Ranch Hand

Joined: Dec 06, 2000
Posts: 31
Oops, it didn't print my start and end blocks.
I use the ASCII Vertical Tab as the start block, and File Separator as the end block.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing text from a TCP/IP socket.
 
Similar Threads
Implementing Toy Web Server
Can I Have Two-Way Communication with Sockets with just one Port?
Parse large String data
do any one from india - chennai have monkhouse book(SCJD)
Multiple sockets cause Threads Hangin