aspose file tools*
The moose likes Threads and Synchronization and the fly likes passing files with threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "passing files with threads" Watch "passing files with threads" New topic
Author

passing files with threads

Kevin Tibbs
Greenhorn

Joined: Apr 16, 2005
Posts: 5
For a class project, I have been developing a simple client/server application that can transmit a file of the clients choosing to a waiting server. The server then chooses where to save the file.

I want my server working with threads so it doesn't have terrible blocking waits.

My trouble is, I recieve the file (as a serialized object) in the thread, and I cant figure out how to sent it back to the server object, so it can be sent back to the GUI so that I can put it into the file chooser so it can be saved to the harddrive. *Sigh*

I don't understand threads very well, and got a feel for how they work from the Sun's examples.

Here is the call creating the thread (sun's page had no assignment in this example)

and here is what I have in the thread so far


Any help is very much appreciated
David Harkness
Ranch Hand

Joined: Aug 07, 2003
Posts: 1646
I don't have time to read all the code right now, but one thing that jumped out at me is that you're serializing the File and sending it to the server. Are you thinking that will send the file's contents? If so, back to the drawing board. You need to read the bytes from the file (using streams) and send them to the server, again using streams from TCP/IP sockets.

If that's not your intention, can you explain exactly what you want to send to the server?
Kevin Tibbs
Greenhorn

Joined: Apr 16, 2005
Posts: 5
>I don't have time to read all the code right now,
Good. Don't bother, it's changed a great deal today, and the threads are now working.

>Are you thinking that will send the file's contents?
Yes, I was. Once I hammered out the problems (and man were there problems) and everything was working, but I was ending up with crap for the result...
I realized I was just basically sending a path to a file that didn't exist on the other end of the socket.


>read the bytes from the file (using streams) and send them to the server,
>again using streams from TCP/IP sockets.

Yeah, still trying to figure this bit out, and could use some direction... but that's a post for the I/O forum and not the threads forum
 
 
subject: passing files with threads