🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: bc.unix
Article #695

Re: Socket : Passive open on a connected socket

#695
From: Kazimir Kylheku
Date: Tue, 27 Feb 1996 00:00
33 lines
1948 bytes
In article <4g1f6n$6r7@bmtlh10.bnr.ca>, Alec Vennos <srikanth@bnr.ca> wrote
using TIN, in his keywords field:

 
 Consider a socket which is bound to a local address and connected to a server
 host. Is it possible to do a listen() and accept system call on the same
 socket (ie, whether the local address portion of the full association
 can be reused). How this can be done?. (I tried with setsockopt() to set
 SO_REUSEADDR option. But it did'nt work).

> (This is implemented in FTP where the same local address is bound to
> port 20 and 21 of the server)

A socket that is already bound and connected is simply not available to use as
a listening socket. Why are you trying to do such a silly thing? Are you
running out of file descriptors that you can't make a new socket with the
socket() system call and listen() on that instead?

The setsockopt() SO_REUSEADDR is used to allow a port number to be reused by
the system when it is released, rather than produce "address in use" errors for
some time.

If you want to have two sockets, one listening, and one connecting, you can
poll them simultaneously with the select() synchronous multiplexing system
call. Select will tell you when a new connection has arrived on the listening
socket, or when the connecting socket is ready for action (i.e. it has
connected, or is ready for writing or reading).

You can't get this functionality by trying to use the same socket for listening
and connecting.


-- 
Technical Details
Message-ID: <4gvs28INNol2@anvil.ugrad.cs.ubc.ca>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <4g1f6n$6r7@bmtlh10.bnr.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114424,d64f94bd9f8574fb
X-Google-Attributes: gid114424,public
From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
Subject: Re: Socket : Passive open on a connected socket
Date: 1996/02/27
Message-ID: <4gvs28INNol2@anvil.ugrad.cs.ubc.ca>
X-Deja-AN: 141592433
references: <4g1f6n$6r7@bmtlh10.bnr.ca>
organization: Computer Science, University of B.C., Vancouver, B.C., Canada
newsgroups: bc.unix