|
|
| Author |
Message |
< Erlang ~ gen_tcp receive - send in different processes |
| Coll |
Posted: Fri Aug 03, 2007 10:01 am |
|
|
|
Joined: 31 Jul 2007
Posts: 6
|
Hello,
Just a quick question, is it safe ta use gen_tcp in active and having one process receive data and another process send data?
I'm so used to see this information in the documents of other languages, is this function thread safe, should you avoid doing this blabla but there is no such information in the Erlang documentation, for a good reason, just want to be sure.
Btw, is gen_tcp part of OTP (is this in the wrong forum)? |
|
|
| Back to top |
|
| Jan Henry Nystrom |
Posted: Fri Aug 03, 2007 10:23 am |
|
|
|
User
Joined: 09 Oct 2006
Posts: 28
Location: Uppsala, Sweden
|
Quote:
Hello,
Just a quick question, is it safe ta use gen_tcp in active and having one process receive data and another process send data?
I'm so used to see this information in the documents of other languages, is this function thread safe, should you avoid doing this blabla but there is no such information in the Erlang documentation, for a good reason, just want to be sure.
Btw, is gen_tcp part of OTP (is this in the wrong forum)?
Hi,
gen_tcp is part of OTP, and it is safe to use. But if you are concerned that you might swamped you may want to use {active, once}. It is described in the examples on the gen_tcp web documentation
/Cheers Henry |
_________________ Jan Henry Nystrom
Training & Research Manager @ Erlang Training and Consulting Ltd
http://www.erlang-consulting.com |
|
| Back to top |
|
| Coll |
Posted: Fri Aug 03, 2007 3:41 pm |
|
|
|
Joined: 31 Jul 2007
Posts: 6
|
Thanks for the quick reply Jan,
The reason for my question is because I don't know when data will arrive so I need to be able to handle data coming in anytime but I also want to be able to send without waiting for new incoming data (polling).
Is it the same if you use passive mode? That it is safe to have one process receive and one sending? You send the socket in to those functions, can that cause any conflict?
I don't know why you would want passive mode anyway, to not overflow your message box? |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|