Erlang/OTP Forums

Author Message

<  Erlang  ~  gen_tcp receive - send in different processes

Coll
Posted: Fri Aug 03, 2007 10:01 am Reply with quote
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)?
View user's profile Send private message
Jan Henry Nystrom
Posted: Fri Aug 03, 2007 10:23 am Reply with quote
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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger ICQ Number
Coll
Posted: Fri Aug 03, 2007 3:41 pm Reply with quote
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?
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

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