Re: Unmatched speed of socket sending and receiving
- From: "Alex Fraser" <me@xxxxxxxxxxx>
- Date: Fri, 28 Sep 2007 13:24:26 +0100
"Yao Qi" <qiyaoltc@xxxxxxxxx> wrote in message
news:m3ps03rwod.fsf@xxxxxxxxxxxx
We write java program to send some data out by socket, and write C
program receive these data from socket. The java program is
multithreaded, and send a lot of number of data by socket, while C
program is single-threaded.
Every time, C program reads data from socket, unpack them, and insert
these data into some lists to maintain them. The speed of receiver (C
program) is not matched to Java program, so the C program slows down the
execution of Java program, because C program could NOT read the data
from socket as soon as possible.
The local buffer has been used in Java program. Before send data by
socket, they are saved in local buffer at first, and send them together
when buffer is full.
This may be counter-productive. If you have some data to send that could be
processed at the other end without waiting for more data (in other words, a
complete "message"), you should generally send it straight away. There are
situations where you would want to do as you describe, but I can't tell if
yours is such a situation.
How could I improve the performance of C program here? Does it help if
I write this C program in a multhreaded way? Thanks for your advice.
Check that it really is too slow: does it often wait for data? If so, then
there is some other limiting factor, eg network bandwidth.
If not, profile to see where in the processing the bottleneck is, and see if
you can fix it (eg by using different algorithms). If the receiver runs on a
multi-processor system, making it multi-threaded may help.
If you find that some part of the processing is a major bottleneck, then
here is a perfect place to post for advice on improving it, but obviously
you'll need to describe the processing required.
Alex
.
- Prev by Date: Re: Pi program and hard disk usage
- Next by Date: Re: Unmatched speed of socket sending and receiving
- Previous by thread: program made in delphi
- Next by thread: Re: Unmatched speed of socket sending and receiving
- Index(es):
Relevant Pages
|