Home Help Center

Reuse sockets?

hotlipshotlips Member Kristian LippertOrganization: Bang & OlufsenProject: Sinope
Hi
Having the interfaces (in pseudo code :-)

interface B
{
...
};

interface A
{
void f([out] B b); // f returns an interface to a B
};

A a = ...

B b;
a.f(b);

Question 1: Will this spawn a new socket connection to B or will they (A and B) use the same connection.

Question 2: If the answer to Q1 is yes (a new connection is spawned) will it then have its own thread (and stack)?

Question 3: How much ressources does a single connection takes up in terms of memory (on both windows and Linux). Stack, allocated mem, and kernal objects!

Best Regards,
Kristian

Comments

  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Which Ice version do you use?

    Invocations on A and B will be sent over the same network connection if A and B are hosted by the same object adapter and if both proxies have similar attributes (same timeout, same connection id, etc), see this FAQ. You'll also find more information on connection establishment and re-use in in the manual and Matthew's article from the Connections newsletter issue #24.

    Connections are objects allocated on the heap so they don't really use any memory on the stack. We don't have precise figures on how much memory a connection consumes. I would expect the C++ objects for a connection to consume initially around 500-1500 bytes (this can vary depending on the transport you use, the concurrency model, how you built Ice-E if you're using Ice-E, etc). A connection also requires and allocates system objects whose memory footprint really depends on the OS (and its configuration) so the best way to figure this out is to run some experiments on your preferred platform. As for the system resources used by an Ice-E for C++ connection, I believe it requires: a network socket, 2 mutexes (or critical section depending on the Windows version), 2 condition variables (on Windows, a condition variable is 1 mutex + 2 semaphores) and 3 event objects (Windows only). It also consumes a thread if you're using the thread-per-connection concurrency model.

    Cheers,
    Benoit.
Sign In or Register to comment.