can anyone suggest a simple way to implement a file transfer?

hello,i've written an messenger application and would like to add to it a very basic file transfer ability : one user selects a file from his pc and sends it to someone in his list.what is the easiest and fastest way to implement such a feature?thanks a lot.
[294 byte] By [AK4ila] at [2007-10-3 3:40:46]
# 1
Java is easy and fast enought to do so.What is your question? How to select file? How to establish conection? How to note other side about transfer? How to transfer binary data?
Michael.Nazarov@sun.coma at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 2
i think what i'm missing is the transfer of binary data, what tools are there for that? how can the reciving side know he got the whole file and the name and type of the file?where can i find a simple code example which transfers any file type?
AK4ila at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 3

What kind of tools do you mean? If you want to use java you should create binary stream and pass data any way you want to.

You can use any of existing protocols or create your own - passing size of followed file, passing special sequence as end of file or something else.

As for code examples - use google or magic "Search Forums" function at the left side of this page.

Michael.Nazarov@sun.coma at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 4
first you need to extend whatever the protocol that you are using to communicate to support binarry data and file information.We cant help you on that unless you explain us the protocol that you are usingRest is just programming
LRMKa at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 5
there aren't easier tools just for files that can take care of all that for me?something that gets the file's place and ip and sends the file to ip over tcp and thats it?
AK4ila at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 6

right now my protocol is using two different ports

one port is my management protocol over udp

the other is for regular messages over tcp,.

for the file transfer i want to use a third port so that everything will work in parallel so i can use any protocol doesn't matter what i've been using so far.

AK4ila at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 7
ftp
ejpa at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 8
BTW there is no need (and not good practice actually) to use own port for each task.
Michael.Nazarov@sun.coma at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 9
but at any time my client can receive some command on udp or some message on tcp or some file, so he needs to listen to all stuff and receive and send in parallel.
AK4ila at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 10
Your client also can send data in chunks with headers contains info about: new chunk of data, message, something else.
Michael.Nazarov@sun.coma at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...
# 11

> but at any time my client can receive some command on

> udp or some message on tcp or some file, so he needs

> to listen to all stuff and receive and send in

> parallel.

This can be done using only one port if you implement multiplexing. And I personally think that server will be much simpler if you use multiplexing streams in same socket instead of multiple sockets

I like the chunks idear becouse you can use chunks to send different content in the same stream if you add some sort of metadata inside the chunk. This will allow to upload multiple files same time. And even resuming broken transfers

LRMKa at 2007-7-14 21:36:26 > top of Java-index,Core,Core APIs...