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 Unix and Windows Communication Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Unix and Windows Communication" Watch "Unix and Windows Communication" New topic
Author

Unix and Windows Communication

Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Hi All,
I have an interesting problem (at least to me). I am experimenting with ObjectInputStream, ObjectOutputStream and sockets. I have written 2 very simple programs; a server and a client. I am constructing a JFrame on the server and when I hit enter, it will send the JFrame to the client. The Client then creates a new JFrame with the state of the one that was sent. This works great if I am communicating from Windows to Windows, but if I have the server on Unix and the Client on Windows, I get 2 errors. On the Server I get: "java.io.IOException: There is no process to read data written to a pipe.
at java.net.SocketOutputStream.socketWrite(Native Method)
at java.net.SocketOutputStream.write(SocketOutputStream.java:95)
at java.io.ObjectOutputStream.drain(ObjectOutputStream.java:1240)
at java.io.ObjectOutputStream.setBlockData(ObjectOutputStream.java:1264)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:385)
at ReplicateServer.<init>(ReplicateServer.java:37)
at ReplicateServer.main(ReplicateServer.java:50)"
On the client I get:
"java.io.InvalidClassException: javax.swing.JFrame; Local class not compatible: stream c
lassdesc serialVersionUID=-7491023444496277500 local class serialVersionUID=91968438219
42654843
at java.io.ObjectStreamClass.validateLocalClass(ObjectStreamClass.java:523)
at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:567)
at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java:936)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:366)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1186)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:386)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:236)
at ReplicateClient.<init>(ReplicateClient.java:20)
at ReplicateClient.main(ReplicateClient.java:46)"
what's interesting is that on the client, you can see that I am getting the JFrame in the stack trace. So it seems that I am at least getting that information from the stream. Is it possible that some, but not all of the JFrame information is getting sent through the stream? Is this a Java/Unix problem? Any ideas on this are greatly appreciated! Thanks!
Barry
Here is the client code:

And here is the server code:

One further note: I thought maybe there is a problem because I was not flushing/closing the stream on the server side. I added the new code, but it did not make any difference.
[ January 21, 2002: Message edited by: Barry Andrews ]
Laudney Ren
Ranch Hand

Joined: Jan 06, 2002
Posts: 111
I skimed over the code. I just wonder, why I haven't seen JFrame be serialized? And it seems br doesn't have any use in the server code.


" Veni, vidi, vici "<br />" I came, I saw, I conquered "
Laudney Ren
Ranch Hand

Joined: Jan 06, 2002
Posts: 111
Well, I know. br is used to block until the user hits enter. But still, I have the question of serialization.
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

Laudney,
I'm not sure I know what you mean. The writeObject() method does the serialization.

Barry
Neil Johnson
Greenhorn

Joined: Jan 22, 2002
Posts: 11
Hi, we have run into something similar and it has to do with the 'magic' numbers that are exchanged when an ObjectOutputStream hooks itself to an ObjectInputStream. Much to our surprise the constructor for this class actually does I/O operations with its counterpart across the connection (yes, I know it does say that in the documentation, I checked, afterward). What it does during this communication is to exchange the magic numbers between the classes and stuff.
To make it work we had to take the class files for the serialized objects that were compiled on one machine and move them over to the other machine. At this point, the magic numbers started to work, and we could send and receive objects. However, if the second machine recompiled the java files into classes again, everything would stop working. So, the class files must be the same on both machines before this will work! And we think the java versions for the VM and class libaries must match as well, otherwise, no luck!
Hope this helps, Neil
 
 
subject: Unix and Windows Communication
 
Threads others viewed
simultaneosly running server class and JFrame, the JFrame wont show the components.
How to transfer a bufferedImage Object?
Help on Serializable
java.io.NotSerializableException and java.io.WriteAbortedException
Communication beween Unix and Windows
developer file tools