Socket 'recv' being slow

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi,

Here's the situation:

There's a server, implemented in Java, that I must create a C++ client for.
Actually, it's just the API that needs to be done, to enable customers to
create their own client in C++. There's already such API implemented in Java
and C#.

Actually, the C++ API already exists too, but we found a bug when we started
to test for heavy charge. Basically, the C++ API, which connects to the
server through Winsock, is about 5 times slower than the C# or Java ones.

After a bit of investigating I found that calls to the 'recv' function
takes between 100 milliseconds and 250 milliseconds. In comparison, the Java
API equivalent socket call takes less than 30 milliseconds, often less than
one millisecond.

I can tell you that the exact same algorithms are used in C++, C# and Java.
The 'recv' is also called the exact same amount of times. Also, the 'send'
call is just as fast in C++.

Because I am not an experienced Winsock programmer, I thought maybe
something was wrong with my implementation, so I tried to use the Boost
library, which has socket implementation. It did not change a thing, it's
still slow to read on the socket.

Another information that can be useful is that this problem only exists when
connecting to a remove server. If the server is local, it has the same speed
than the Java and C# implementations, maybe even faster.

Finally, we also have a SOAP implementation of the client API. This one is
also faster than the C++ socket API. If you use the SOAP API locally though,
it becomes slower.

I hope my problem is a simple one. Basically, I would guess that it has
something to do with socket options or something like that. By the way, we're
using TCP/IP.

Also, the code has to be Linux compatible. It has been tested on Linux
machine and it's just as slow as on a Windows machine.

Thanks,
chuby.qc
.



Relevant Pages

  • Re: simple web programming options
    ... And that I have seen from CGI/FCGI, Java ... PHP seems to provide the best API of ready-to-use ... doing CGIs specifically and scripted access to databases. ... I recommend PHP highest for language. ...
    (comp.programming)
  • Non destructive read of socket
    ... Is it possible to do a non-destructive read on a socket in Java? ... MSG_PEEK flag. ... I am implementing an API in Java which needs to send a "are you alive" ...
    (comp.lang.java.programmer)
  • Re: to RG - Lisp lunacy and Perl psychosis
    ... about ABCL and was hoping to stick with a familiar ANSI implementation ... The Java access API is derived from ACL's jlinker (http:// ... ACL's API assumes the JVM is a different process, ... It is mostly ANSI compliant; it lacks the long form of define-method- ...
    (comp.lang.lisp)
  • Re: what is encapsulation in an interface ?
    ... you're promoting ignorance of the collections API. ... be aware of it in order to collect pay as a Java programmer. ... How fortunate it is for us Java programmers that you aren't the world ... very short "for" loop was terrible and no ...
    (comp.lang.java.programmer)
  • Re: Shortage of qualified Java programmers
    ... library of Java is what you have computers for -- not people. ... every detail of the API. ... to figure out how a Comparator works given the Javadocs. ... programmers written by Bill Venners. ...
    (comp.lang.java.programmer)