Socket 'recv' being slow
- From: chuby.qc <chuby.qc@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 24 Jul 2008 10:50:00 -0700
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
.
- Follow-Ups:
- Re: Socket 'recv' being slow
- From: Dave Lowther
- Re: Socket 'recv' being slow
- Prev by Date: Re: getaddrinfo return only one IP address
- Next by Date: Re: Socket 'recv' being slow
- Previous by thread: WSAAddressToString and IPv6 on xp
- Next by thread: Re: Socket 'recv' being slow
- Index(es):
Relevant Pages
|