Re: Unmatched speed of socket sending and receiving



"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


.



Relevant Pages

  • Re: Embedded java ?
    ... Could I write a Java program to run on a cell phone and open a socket ... our unix machine. ...
    (comp.lang.java.help)
  • Re: c prog socket connect to java program
    ... [invalid group com.lang.java.developer removed] ... > my c program wants to send a message to java program through socket. ... and read again in a loop until the entire message has been ...
    (comp.lang.java.programmer)
  • Re: Unmatched speed of socket sending and receiving
    ... We write java program to send some data out by socket, ... The local buffer has been used in Java program. ... This can be easily checked by looking at the C program's CPU usage. ...
    (comp.programming)
  • Re: Unmatched speed of socket sending and receiving
    ... We write java program to send some data out by socket, ... The local buffer has been used in Java program. ... This can be easily checked by looking at the C program's CPU usage. ...
    (comp.programming)