• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

send files over the socket

 
Bobes Calin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a litle problem (i think) on my client server application. The aplication sends one file and not all that i give it to it.

here is the code for the server....



and for the client....



Can anybody show me how to send all the files? Thank you!

Calin
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like your client should send all the files, but your server will only read one. "receiveFileFromClient()" should be called in a loop, right?
 
Bobes Calin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes the server reads only the fisrt file. How can i do the loop? on what criteria?

Thank you!

Calin
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe the client could send the number of files to expect first, and then you could just use a "for" loop.
 
Bobes Calin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to send the number of files that are in the File[] array

in the client sendFileToServer()



and the server receiveFileFromClient()



but hte same thing, only the first file is send.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to read the file count from the socket only once, and store it in a variable, and then use that variable in the for loop. If you do this:



then the count gets changed to some random value each time through the loop, and that isn't good!
 
Bobes Calin
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes you are right with the count.



i put it out from the loop and initialized with a with an int value on the server



but the same thing only one file is copied
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic