[erlang-questions] tcp sockets - not clear

Oscar Hellström oscar@REDACTED
Mon Oct 6 20:35:19 CEST 2008


Hi,

I'm assuming that a object is something running in a separate thread, which means that you will have to have a thread safe implementation of the send() function to be able to get the messages through without problems. AFAIK know at least the POSIX implementations are thread safe. Another important part here is that the whole message must be put on the wire before any part of any other message is, which actually means that the send() function need to support atomicy. If this is not the case for you send() function you probably need to serialise the sending. You can read more about this here: http://www.almaden.ibm.com/cs/people/marksmith/sendmsg.html

Keep in mind that TCP packages can be fragmented on the way, and you need to assemble them yourself unless you use use the {packet, 1|2|4} option (and implement that on the flash side), i.e. you need some defined protocol. If you're using a text based protocol this is less of a problem (or more depending on who you are) I guess.

>From the erlang side we seem to have the same issue that we need to serialise the data to be absolutely sure that messages are not intervened (since the inet_drv.c essentially calls send() at some point). Someone please correct me if I'm wrong here.

Hope this helps.

----- Original Message -----
From: "deepblue_other" <cktgatb@REDACTED>
To: erlang-questions@REDACTED
Sent: Sunday, 5 October, 2008 9:07:08 AM GMT -08:00 US/Canada Pacific
Subject: [erlang-questions]  tcp sockets - not clear


hello everyone
Im building a system with a Flash front-end and an Erlang back-end and have
some confusion in a case where there is a single socket on the back-end per
user (per single socket on the front-end).
I want to have multiple independent objects on the front-end send messages
to the back-end, but am not sure how the simultaneous transmission would be
handled. This probably stems from my somewhat clowdly understanding of TCP.
Say there are 3 objects that initiate a send() method on the front-end
(almost at the same time) and send a semi large message each to the
back-end. Each message would be ID'd by the front-end so that when received
back it can be routed to the appropriate callback. Is this possible?
since the packets are being assembled in the {tcp, Socket, Data} pattern
match, peace by peace, would the correct peaces of the individual messages
be stiched together? (doesnt seem like they would).

if that wont work then I would just have the serialize the
sending/receiving, which is not too horrible...

thanks 
-- 
View this message in context: http://www.nabble.com/tcp-sockets---not-clear-tp19826070p19826070.html
Sent from the Erlang Questions mailing list archive at Nabble.com.

Best regards
-- 
Oscar Hellström, oscar@REDACTED
Phone:  +44 (0)798 45 44 773
Mobile: +44 (0)207 65 50 337
Web:    http://www.erlang-consulting.com




More information about the erlang-questions mailing list