*BSD News Article 28750


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!foxhound.dsto.gov.au!fang.dsto.gov.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!news.cs.su.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!cs.utexas.edu!convex!grefen
From: grefen@convex.com (Stefan Grefen)
Newsgroups: comp.unix.bsd
Subject: Re: sockets
Date: 24 Mar 1994 19:38:53 GMT
Organization: CONVEX Computer Corp, Richardson, TX USA
Lines: 29
Message-ID: <2msq8d$onm@convex.convex.com>
References: <2mspg7$arv@nigel.msen.com>
NNTP-Posting-Host: hydra.convex.com
Keywords: sockets connect disconnect

In article <2mspg7$arv@nigel.msen.com>,
Doug Haanpaa <dhaanpaa@cybernet.com> wrote:
>Here's what I want to do:  First, open a socket to
>a certain address and port.  No problem, did it, it worked.
>Now I want to close that socket, and after some period of
>time, open it back up again.  However, when I try to open 
>it back up again (another call to "socket" and another call
>to "connect"), it won't let me.  I get an message saying that
>the socket's already in use.  Obviously "close" won't do the

I guess you're using a TCP (STREAM) socket. After closing this socket
lingers for some amount of time to capture all old duplicates from the
network. You can force it to reuse the addr by issuing a 
setsockopt(..,SO_REUSEADDR,...) call.

Stefan

>job of really disconnecting the socket.  Is the "unlink" 
>function what I want?  If so, how do I get the arguments it
>needs?  HELP!  Thanks very much in advance to anyone that can
>help!  -Doug.
>
>


-- 
Stefan Grefen                          Convex Computer GmbH, Frankfurt, Germany
grefen@convex.com		       Phone: +49-69-665270