> >       Will the IP address of the client host ever enter buf[] if the
> >       accept() is _not_ uncommented?
> >  I don't need portability, since this is for use within the FreeBSD inetd
> >  exclusively.
>
> Well if you CAN'T do it in FreeBSD, is there an OS we can copy the API from
> that DOES do it? (Providing it isn't too braindamaged of course.. :)

There is an API that can do it: 
System V Release 4 Streams and TLI (Transport Layer Interface).    

TLI is not based on systems calls doing the job.
It is based on message transfer between the user and some kernel entity.
  
Incoming calls are indicated by sending a T_CONN_IND message (connect
indication) to the user process. Then the user process opens a
second TLI stream (like using the socket() system call) and sends a
T_CONN_CON message (connect confirmation) to the kernel entity.

The TLI API is based on OSI. It doesn't provide much more functionality
than BSD sockets. Two APIs for the same task isn't very useful.
So you should better hack the BSD sockets to fit your needs.

A similar functionality in BSD-world would be:

        (1) use recvfrom() instead of accept() on the socket
                TLI: use getmsg() to receive the T_CONN_IND
        (2) create a new socket using socket()
                TLI: use open() to open a new stream
        (3) accept the connection using an ioctl()
                TLI: send T_CONN_CON to accept the connection
or
        (2) reject the connection using an ioctl()
                TLI: send T_DISCON_REQ to reject the connection

Here's an overview of the TLI messages:

TLI (user)      TLI (kernel)    BSD socket

T_INFO_REQ      T_INFO_ACK      -
T_BIND_REQ      T_BIND_ACK      bind()
T_UNBIND_REQ    -               -
T_OPTMGMT_REQ   T_OPTMGMT_ACK   setsockopt()
-               T_ERROR_ACK     errno
T_CONN_REQ      T_CONN_RES      connect()
T_CONN_CON      T_CONN_IND      accept()
T_DISCON_REQ    -               shutdown()
-               T_DISCON_IND    errno
T_ORDREL_REQ    -               shutdown()
T_DATA_REQ      -               send() / sendto() / write()
-               T_DATA_IND      recv() / recvfrom() / read()
T_EXDATA_REQ    -               send() / sendto()
-               T_EXDATA_IND    recv() / recvfrom()
T_UNITDATA_REQ  -               send() / sendto() / write()
-               T_UNITDATA_IND  recv() / recvfrom() / read()
-               T_UDERROR_IND   recv() / recvfrom() / read() & errno

; Bodo

-- 
Bodo Rüskamp, b...@rueskamp.com, 51°55' N 7°41' E
(1) Elvis is alive.
(2) Dinosaurs too. <http://www.lochness.scotland.net/camera.htm>
(3) The next millenium starts on January 1st 2000.


To Unsubscribe: send mail to majord...@freebsd.org
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to