Sorry for that. I was looking in thread but i didnt get a solution for Multi file transfer using socket communication in java, could you please guide , My code is transferring only one file at a time..Henry Wong wrote:https://coderanch.com/how-to/java/UseTheForumNotEmail
Riyas Hameed wrote:
Sorry for that. I was looking in thread but i didnt get a solution for Multi file transfer using socket communication in java, could you please guide , My code is transferring only one file at a time..Henry Wong wrote:https://coderanch.com/how-to/java/UseTheForumNotEmail
I am new to this concept. for file transfering which is the best mechanism in java , either Socket communication or FTP?
Jeff Verdegan wrote:
Riyas Hameed wrote:
Sorry for that. I was looking in thread but i didnt get a solution for Multi file transfer using socket communication in java, could you please guide , My code is transferring only one file at a time..Henry Wong wrote:https://coderanch.com/how-to/java/UseTheForumNotEmail
If you know how to do one file, then you know how to do multiple files.
I am new to this concept. for file transfering which is the best mechanism in java , either Socket communication or FTP?
There is no single "best" mechanism. The best one for you in this particular situation is the one that best meets your requirements in this particular situation.
Riyas Hameed wrote:
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Riyas Hameed wrote:Thanks a lot , As per your words, I did the changes , Its working fine..I jus added one more while loop in server part.
Now its working fine, This client application will run more than 500 Machines.So how can i make the best perofrmance .please suggest me to do this part. Thanks in Advacne.
Riyas Hameed wrote:Now its working fine, This client application will run more than 500 Machines.So how can i make the best perofrmance .please suggest me to do this part. Thanks in Advacne.
Jeff Verdegan wrote:
Riyas Hameed wrote:Now its working fine, This client application will run more than 500 Machines.So how can i make the best perofrmance .please suggest me to do this part. Thanks in Advacne.
For parallel I/O such as this, the two main general approaches to optimize performance are 1) buffering, and 2) multithreading. You're already doing #1, although you may find that tweaking your buffer size up or down helps somewhat, so the main thing now is to use mulitple threads.
If I understand your scenario correctly you have many clients receiving files from a server and storing them on their local file systems. So you'll want multithreading in two places. 1) On the server, you'll want multiple threads to handle clients' requests. You'll have to experiment to find the optimal number. It could be anywhere between a few threads and a few hundred. 2) On the client, you might want two threads--one for reading from the server and one for writing to the file. Or that might not help at all. Impossible to say without trying it in the specific situation in which it will be used.
Other than that, the only thing you can do is see if the app is meeting your performance requirements, and if not, use a profiler to find bottlenecks.
Riyas Hameed wrote:
Thank a lot for your support , In my requirement , All clients will transfer the files to the centralized server and save in server location.
So I have to create two threads in server side one for reading and one for writing ? please correct me If i am wrong. I have implemented thread concept in server side
, some time some of the bytes are missing while writing in server side , now i am facing the issue
. can i share my code here ??
Jeff Verdegan wrote:
Riyas Hameed wrote:
Thank a lot for your support , In my requirement , All clients will transfer the files to the centralized server and save in server location.
So I have to create two threads in server side one for reading and one for writing ? please correct me If i am wrong. I have implemented thread concept in server side
If all 500 clients are sending their files at the same time, I would start with something like 10-20 threads reading from clients, putting into queues (1 queue per destination file) and 1-5 threads reading from the queues and writing to files. I'd probably use ThreadPoolExecutors and ArrayBlockingQueues or LinkedBlockingQueues.
Since I don't know your system or your requirements at all, this is just starting point. You'll have to do some research into the relevant classes, and do some testing and tweaking on your setup to see what works best.
, some time some of the bytes are missing while writing in server side , now i am facing the issue
Then there's a bug in your code.
. can i share my code here ??
Probably the whole thing will be too much for anybody to want to read. You'll have better luck if you can create an SSCCE that shows the relevant parts of your code and ideally demonstrates the problem, without any extra stuff that's not directly related to the problem.
Riyas Hameed wrote:
Thank you very much, yes I have to go through all other thing which you have mentioned in the previous message . I am not sure but atleast minimum 50 to 100 Machine will send a file to server at a time . i will discuss with them and come back to you ..Jeff Verdegan wrote:
If all 500 clients are sending their files at the same time, I would start with something like 10-20 threads reading from clients, putting into queues (1 queue per destination file) and 1-5 threads reading from the queues and writing to files. I'd probably use ThreadPoolExecutors and ArrayBlockingQueues or LinkedBlockingQueues. Since I don't know your system or your requirements at all, this is just starting point. You'll have to do some research into the relevant classes, and do some testing and tweaking on your setup to see what works best.Riyas Hameed wrote: Thank a lot for your support , In my requirement , All clients will transfer the files to the centralized server and save in server location. So I have to create two threads in server side one for reading and one for writing ? please correct me If i am wrong. I have implemented thread concept in server side
Then there's a bug in your code., some time some of the bytes are missing while writing in server side , now i am facing the issue
Probably the whole thing will be too much for anybody to want to read. You'll have better luck if you can create an SSCCE that shows the relevant parts of your code and ideally demonstrates the problem, without any extra stuff that's not directly related to the problem.. can i share my code here ??
Paul Clapham wrote:If you read the documentation for the "read" method you're using, you will see that it returns -1 when it gets to the end of the stream. But you aren't checking for that. You are also considering 0 as a reason to stop reading.
But when the "read" method returns 0, that just means it has no bytes for you just at the moment. It doesn't mean that there will never be any more bytes. So fix your end-of-stream tests.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Rob Spoor wrote:
Riyas Hameed wrote:
0 is a valid return code for InputStream.read(byte[]). It means that currently no data is available, but in the future there still may be. -1 is the only indicator that there will not be any data anymore, so change the > into >=.
Rob, I tried already what you said in the above conversation, even though i got the same error only, extremely sorry, forget to noticed that one.
Riyas Hameed wrote:
Rob Spoor wrote:
Riyas Hameed wrote:
0 is a valid return code for InputStream.read(byte[]). It means that currently no data is available, but in the future there still may be. -1 is the only indicator that there will not be any data anymore, so change the > into >=.
Rob, I tried already what you said in the above conversation, even though i got the same error only, extremely sorry, forget to noticed that one.
Riyas Hameed wrote:
Rob Spoor wrote:
Riyas Hameed wrote:
0 is a valid return code for InputStream.read(byte[]). It means that currently no data is available, but in the future there still may be. -1 is the only indicator that there will not be any data anymore, so change the > into >=.
Rob, I tried already what you said in the above conversation, even though i got the same error only, extremely sorry, forget to noticed that one.
Riyas Hameed wrote:
Riyas Hameed wrote:
Rob Spoor wrote:
Riyas Hameed wrote:
0 is a valid return code for InputStream.read(byte[]). It means that currently no data is available, but in the future there still may be. -1 is the only indicator that there will not be any data anymore, so change the > into >=.
Rob, I tried already what you said in the above conversation, even though i got the same error only, extremely sorry, forget to noticed that one.
Why is the word "abbreviation" so long? And this ad is so short?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|