How to implement multiple sockets per client?
tty@REDACTED
tty@REDACTED
Sat Aug 26 06:31:24 CEST 2006
Hmm....to address your question of socket failover you can rely on the OS, in particular Unix/Linux/BSD and its Stream Control Transmission Protocol (SCTP). See http://www.sctp.org/. This might also address your large outbound traffic needs.
t
-------- Original Message --------
From: Jeff Crane <jefcrane@REDACTED>
Apparently from: owner-erlang-questions@REDACTED
To: erlang-questions@REDACTED
Subject: Re: How to implement multiple sockets per client?
Date: Fri, 25 Aug 2006 20:31:40 -0700 (PDT)
> I have a simple single connection server, no problem.
>
> I would think that there would be quite an advantage
> to dual sockets beyond the restriction of protocols.
> More efficient reading/writing over time, failover in
> the case of a socket collapse due to unexpected IO
> behavior in development.
>
> I'm not sure how the timeline of which languages had a
> library that provided a bidirectional non-blocking
> network socket applies. Just because there exists a
> paradigm, it doesnt naturally follow that it's been
> implemented in erlang by default. The question is how
> one might do dual (input/output) sockets in in erlang
> per client. The answer seems to be, use 1 socket (and
> verify the client via protocol...IP is unreliable) or
> clone the socket on accept.
>
> My traffic IN to my server is > 1/1000 my traffic
> OUT...and my traffic OUT is lots of data as fast as
> possible (machine state updates). Is there such a
> thing as a pure input/output socket in erlang? I was
> under the impression that "receive" was basically a
> select() so I figured dual socket was the way to go.
>
> --- Pupeno <pupeno@REDACTED> wrote:
>
> > On Friday 25 August 2006 22:31, Jeff Crane wrote:
> > > I want to have a client connect to my barebones
> > server
> > > on 2 sockets. How are you supposed to ensure that
> > a
> > > second connection is from the same client?
> >
> > You can check for the IP.
> >
> > > Is there a way to spawn 2 sockets from an accept?
> >
> > Now, you listen and accept incoming connections. On
> > accept launch a new thread
> > and you can accept as many connections (creating as
> > many sockets) as you
> > want. You'll have to limit it to two of course. I'd
> > code this as two
> > gen_servers, one the launcher, listening for
> > incoming connections and keeping
> > track of who connected and how many times and then
> > another to handle the
> > connection itself (hint: there's a function to
> > reassign the ownership of the
> > socket to a new process).
> >
> > > Do I have to listen then initiate to do this
> > > correctly?
> >
> > Have you coded a simple server first ? I'd recommend
> > to star there.
> >
> > > The 2 sockets would be one for reading (input
> > messages
> > > from client) and one for sending (output messages
> > to client).
> >
> > You can do reading and witting on the same socket,
> > on the same connection. It
> > has been that way for what ? 20 years ? 30 years ?
> >
> > --
> > Pupeno <pupeno@REDACTED> (http://pupeno.com)
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
More information about the erlang-questions
mailing list