Subject: Re: Obtaining client IP address before accept(2)
To: David Laight <david@l8s.co.uk>
From: Rob Newberry <robthedude@mac.com>
List: tech-kern
Date: 07/14/2005 13:26:26
>> STREAMS and he XTI interface did have a concept of this -- you could
>> get called back when the TCP SYN arrive. You had the option of
>> "accepting" the connection (which would reply with another TCP SYN)
>> or rejecting it (sending a TCP RST).
>
> Not on any of the STREAMs based TCP implementations I've seen.
> IIRC the XTI for TCP explicitely states that the SYN-ACK will be
> sent before any handshake with the application takes place.
> (The same isn't true for typical implemetations of other protocols
> using the XTI/TLI and STREAMS).
I think this is how it work.
Using the STREAMS API, you:
- use t_open to create a socket in non-blocking mode
- use t_bind and t_listen to start waiting for incoming connections
- use t_look to wait for a T_CONNECT event
At this point, you have the option of accepting the connection (using
t_accept) or disconnecting (using t_snddis). t_accept will send a
TCP_SYN and completion the open, while t_snddis will send a TCP_RST
(since the connection is not yet open).
The Mac OS STREAMS implementation (based on Mentat's code) made the
t_look stuff a little easier by allowing you to specify a callback
when the event came in, so it was a little easier to handle.
Rob