gen_tcp:accept/{1,2} in passive mode?

Peter H|gfeldt peter@REDACTED
Mon Dec 4 20:30:58 CET 2000


Sam,

we have internally an inofficial FAQ which considers your problem:

Q.11 : 	One process in my application is typically hanging in a call to
	gen_tcp:accept/1 waiting for a connection request. How do I perform
	code change for that process? 

A: 	Let the implementation be such that another process holds the
	listen socket and is linked to the process hanging in
	gen_tcp:accept/1. Specify an update code upgrade instruction with
	a very short timeout, which will cause the process to be
	killed almost immediately by the release handler, before the new
	version of the call-back module for the process is loaded. Then
	let the other process restart the process calling gen_tcp:accept/1. 

/Peter

-------------------------------------------------------------------------

Peter Högfeldt			e-mail  : peter@REDACTED
Open Telecom Platform		Phone:  : +46 (8) 727 57 58
Ericsson Utvecklings AB		Mobile	: +46  070-519 57 51
S-126 25 STOCKHOLM		Fax:	: +46 (8) 727 5775
Office address:			Armborstvägen 1, Älvsjö

On Mon, 4 Dec 2000, Samuel Tardieu wrote:

> I use gen_tcp:accept{1,2} a lot when doing servers, and I don't like the
> fact that I cannot passively wait for connections, in a gen_server for example.
> How do you deal with code change and a process being blocked in an accept
> call? You can always use a timeout, but in this case you generate some
> load when you exit the timeout just in case code needs to be changed.
> 
> Wouldn't it be possible to set the accepting socket in passive mode, and
> receive a message {Port, {accept, NewSocket, Origin}} for example when
> a new connection arrives?
> 
>   Sam
> 
> 




More information about the erlang-questions mailing list