Tux

...making Linux just a little more fun!

Problem in Client when spawning multiple connections on socket

Amit Saha [amitsaha.in at gmail.com]
Wed, 17 Jan 2007 22:02:59 -0800

Hi list! i need your advice. The situation is like this

We have a situation where we have a DEC Alpha Server with a Concurrent Server which spawns a child to every process that we connect to. On a Linux box on the same network, we have built a client which connects to the server ,we see the connection and every things is good. At this time we try to invoke another instance of the this client, at this point it kills the first connection and the second one connects. We are passing the Internet address of the server to connect.

If we have the client on the same server we can spawn multiple instances and every instance connects, in this case though the address 127.0.0.1 or the local host.

Any pointers as to how we can have multiple client using the same socket.

-- 
Amit Kumar Saha
GSM :+91 9903140286
http://amitsaha.in.googlepages.com

Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]
Thu, 18 Jan 2007 13:36:37 +0700

Dear Amit Saha

> Hi list!
> i need your advice. The situation is like this
>
>   
let me try my luck...

> We have a situation where we have a DEC Alpha Server with a Concurrent
> Server which spawns a child to every process that we connect to. On a
> Linux box on the same network, we have built a client which connects
> to the server ,we see the connection and every things is good. At this
> time we try to invoke another instance of the this client, at this
> point it kills the first connection and the second one connects. We
> are passing the Internet address of the server to connect.
>
>   

OK, I am stressing to one fact here. Anytime another instance of client tries to connect to the DEC Server, the server will kill the previous established connection? Do I conclude it correctly?

> If we have the client on the same server we can spawn multiple
> instances and every instance connects, in this case though the address
> 127.0.0.1 or the local host.
>
>   
OK, another point here is, if the connection is made within the same server (so the server also acts as the client), everything will run fine even though you spawn many instance of clients?

> Any pointers as to how we can have multiple client using the same socket.
>   
I have untested idea. Fork() new instance of clients but make the socket descriptor a shared property between those instance. Then, do somekind of coordination between these forked clients so whenever one client writes, the other waits until it finishes. The same applies on reading case, maybe use select() and observe the incoming data to decide which client is in charge with the received data.

All in all, in this multiplexing situation, you surely need a tag or something to mark the packet destination, I mean to distinguish the real acceptor of the packet. IMHO you must do this since the clients use the same socket, that means same local port, same socket descriptor and so on.

I hope you do get my explanation correctly. If not, just ask again....

regards,

Mulyadi


Top    Back


Mulyadi Santosa [mulyadi.santosa at gmail.com]
Thu, 18 Jan 2007 22:28:41 +0700

Dear Amit...

> the problem was posted to me by some one else,so i am posting your
> reply to that person.
OK, thanks a lot, I didn't know that. I thought it was you who posted the question.

regards,

Mulyadi


Top    Back


Neil Youngman [ny at youngman.org.uk]
Thu, 18 Jan 2007 19:28:33 +0000

On or around Thursday 18 January 2007 06:02, Amit Saha reorganised a bunch of electrons to form the message:

> Hi list!
> i need your advice. The situation is like this
>
> We have a situation where we have a DEC Alpha Server with a Concurrent
> Server which spawns a child to every process that we connect to. On a
> Linux box on the same network, we have built a client which connects
> to the server ,we see the connection and every things is good. At this
> time we try to invoke another instance of the this client, at this
> point it kills the first connection and the second one connects. We
> are passing the Internet address of the server to connect.
>
> If we have the client on the same server we can spawn multiple
> instances and every instance connects, in this case though the address
> 127.0.0.1 or the local host.
>
> Any pointers as to how we can have multiple client using the same socket.

Is this C code?

Obviously something isn't right, but it's hard to comment without more details.

Can you show us seeing the code that handles the connections and spawns the new process?

What error code is returned when the first process loses it's connection? You do that, don't you?

Have you tried compiling/running the server on another box?

Have you tried the local equivalent of Linux's strace?

Neil Youngman


Top    Back