| Author |
send files over the socket
|
Bobes Calin
Greenhorn
Joined: Nov 13, 2008
Posts: 14
|
|
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
Joined: Jul 08, 2003
Posts: 24041
|
|
|
Looks like your client should send all the files, but your server will only read one. "receiveFileFromClient()" should be called in a loop, right?
|
[Jess in Action][AskingGoodQuestions]
|
 |
Bobes Calin
Greenhorn
Joined: Nov 13, 2008
Posts: 14
|
|
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
Joined: Jul 08, 2003
Posts: 24041
|
|
|
Maybe the client could send the number of files to expect first, and then you could just use a "for" loop.
|
 |
Bobes Calin
Greenhorn
Joined: Nov 13, 2008
Posts: 14
|
|
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
Joined: Jul 08, 2003
Posts: 24041
|
|
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
Joined: Nov 13, 2008
Posts: 14
|
|
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
|
 |
 |
|
|
subject: send files over the socket
|
|
|