aspose file tools*
The moose likes I/O and Streams and the fly likes Server and Client 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 "Server and Client" Watch "Server and Client" New topic
Author

Server and Client

feda alshahwan
Ranch Hand

Joined: Jul 26, 2008
Posts: 170
I am trying to create a server that sends objectstreamoutput to a client in array bytes and client reading it and displaying it to the screen but I am stuck in reading and writting the bytes here is my code for server:
And here is my client code:


The output for client is:
run:
The message read by client [B@3e25a5
The length of the message read by client 0
[B@3e25a5
BUILD SUCCESSFUL (total time: 0 seconds)


How to solve it please?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8912
    
    8

Welcome to the JavaRanch.
First thing I see is that you use available(). AvailableDoesntDoWhatYouThinkItDoes
Next, you are creating object streams, but you aren't reading and writing objects. Have a look at the Java Tutorial page on Object Streams for how to use them correctly.


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

Joined: Jul 26, 2008
Posts: 170
I am writing using in the webserver and reading using in the client
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8912
    
    8

I see that. Why aren't you just writing the String objects? Why convert the Strings to byte arrays?
Also, on the receiving end, you are using available() to determine the length of the byte array. As I pointed out before, available doesn't do what you want it to do.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Server and Client