From leo@solvo.ru Thu Sep 27 10:57:43 2001
Received: from condor.solvo.ru (condor.solvo.ru [195.201.44.91])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8R8vhv04555
	for <prolog@swi.psy.uva.nl>; Thu, 27 Sep 2001 10:57:43 +0200 (MET DST)
Received: from localhost (leo@localhost)
	by condor.solvo.ru (8.9.3/8.9.3) with ESMTP id MAA21656
	for <prolog@swi.psy.uva.nl>; Thu, 27 Sep 2001 12:57:37 +0400
X-Authentication-Warning: condor.solvo.ru: leo owned process doing -bs
Date: Thu, 27 Sep 2001 12:57:37 +0400 (MSD)
From: "Leonid V. Khramov" <leo@solvo.ru>
To: Prolog mailing list <prolog@swi.psy.uva.nl>
Message-ID: <Pine.LNX.4.21.0109271237140.21646-100000@condor.solvo.ru>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Subject: [SWIPL] tcp_socket and REUSEADDR

Hi!

First of all thanks for fixing bug in wait_for_it, it works fine now.

And i have another problem in tcp library.
When i open socket for server use , tcp library didn't set SO_REUSEADDR
option on soket. So if server crashes and restarts it can't allocate socket
again because address still in use (OS wait some timeout).

For fix this problem in C, you need to call:
if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,&val,sizeof(val))==-1)
{
  return(tcp_error_term(errno, NULL));
}

after creating a socket.

I hope this helps to fix the problem.
Thank you.
-- 
Best regards,
Leo <leo@solvo.ru>
Solvo Ltd. 
St.Petersburg, Russia

