Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RMI, old Sockets, new Channels? Help!!!



Some background: I'm writing a Swing application that connects to a central database. I coach a quiz bowl team and want the ability for students to enter questions and quiz themselves while only having one copy of questions.

Because the app needs to talk to the server (to say, "add a new question to the database" or "give me a list of all the subjects") and the server needs to talk to the app (to say, "someone changed the list of subjects" or "please log in"), I had originally set up InputStreams and OutputStreams at both ends of the connection. I was passing information back and forth by using ObjectInputStream and ObjectOutputStream so that I could throw the information in a Serializable class and send an object to represent the information across the Socket.

Is it possible to leave the Socket open and continue to pass information back and forth this way? I ask because I keep getting StreamCorruptedExceptions with no extra information about why. If I can't keep the Streams open and instead must close them after each interchange, how do I keep track of the state of each client app? (I was doing it in the Thread that got spawned to handle each incoming request.)

The most frustrating part of this is that I got it to the point where the app would get a lot of information from the server, set up the UI, and run, but started running into trouble when a second query for the list of subjects after adding a new one and have been unable to get any farther. (I tried resetting the ObjectOutputStreams after each write, but still everything dies at the same point.)

Any help appreciated, including advice about how I should really be doing this. I've thought about RMI, but I really need both the app and the server to be able to initiate contact, and from my quick perusal of RMI, it seems like all the remote objects have to live on one machine. I've also looked at the NIO package, but can't figure out what it really gains me except the need to translate all my data objects into byte arrays so I can ship them back and forth. I don't really need non-blocking I/O (I don't think) because there isn't really much that either side of the connection can do while it's waiting for data from the other and I should never have more than 30 people connected to the server at any one time.

Thanks for any help,
Todd

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.