How to implement multiple sockets per client?
tty@REDACTED
tty@REDACTED
Sat Aug 26 06:01:36 CEST 2006
-------- Original Message --------
From: Jeff Crane <jefcrane@REDACTED>
Apparently from: owner-erlang-questions@REDACTED
To: erlang-questions@REDACTED
Subject: How to implement multiple sockets per client?
Date: Fri, 25 Aug 2006 15:31:25 -0700 (PDT)
> Is there a way to spawn 2 sockets from an accept?
> Do I have to listen then initiate to do this
> correctly?
You basically do the accept. This gives you 1 socket. Then in the next line you initiate a gen_tcp:connect back to your client. This gives you your 2nd socket.
In effect you make your client a server as well.
Usually after the accept you wait for your client to send some data, typically the client port for a callback. Oracle does something similar.
However as Pupeno indicated a single socket can be use for bi-directional data. To be honest I'm not even sure how to set a socket for only uni-directional data (in Erlang).
Furthur more if you insist on doing this, sit down and have a good chat with your network admin first. The client port callback mechanism complicates firewall rules or more correctly open way more ports then needed. Its one reason we dislike allowing open access to Oracle.
t
More information about the erlang-questions
mailing list