How to implement multiple sockets per client?
Sat Aug 26 05:31:40 CEST 2006
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 <> wrote:
> On Friday 25 August 2006 22:31, Jeff Crane wrote:
> > I want to have a client connect to my barebones
> > on 2 sockets. How are you supposed to ensure that
> > 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
> > 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 <> (http://pupeno.com)
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the erlang-questions