In BSD sockets, the concept "address" itself just means both the "host" and "port", when applying to internet protocol (IP). There're other type of addresses which doesn't have a "port" in BSD sockets, i.e. the UNIX domain sockets.
If you took a look at sb-bsd-sockets' implementation code of SOCKET-ACCEPT, you'll find that it's not IP specific but quite general. It operate on C struct "sockaddr" but "sockaddr_in". The number of returned multiple values of SOCKET-ACCEPT will be determined by specific usage:
;;; contrib/sb-bsd-sockets/sockets.lisp, L105
(defmethod socket-accept ((socket socket))
(with-sockaddr-for (socket sockaddr)
(let ((fd (sockint::accept (socket-file-descriptor socket)
((and (= fd -1)
(list sockint::EAGAIN sockint::EINTR)))
((= fd -1) (socket-error "accept"))
(t (apply #'values
(let ((s (make-instance (class-of socket)
:type (socket-type socket)
:protocol (socket-protocol socket)
(sb-ext:finalize s (lambda () (sockint::close fd))
(multiple-value-list (bits-of-sockaddr socket sockaddr))))))))
Try understand the last call of (apply #'values ...), this means the number of values depend on the socket type. For IP (TCP, UDP), I believe it contains the "port" part.
Hope this helps.
在 2011-7-31，14:22， Matthew Mondor 写道：
> On Sat, 30 Jul 2011 00:44:58 -0400
> Matthew Mondor <mm_lists@...> wrote:
> Sorry for replying under my own message; I had a setting set in the ML
> manager to avoid duplicates when I'm CCed which I now disabled (this
> address only allows mail from mailing lists, so the personal message
> bounced, the ML manager didn't send me a duplicate from the ML address).
>> Does it? On my system, it returns a third value that is the port number
>> for remote inet socket. sb-bsd-sockets:socket-peername also returns the
> When I realized the port was missing in ECL, I admit that I only
> checked the documentation
> and the following on 1.0.49:
> * (describe #'SB-BSD-SOCKETS:SOCKET-ACCEPT)
> #<STANDARD-GENERIC-FUNCTION SB-BSD-SOCKETS:SOCKET-ACCEPT (1)>
> Lambda-list: (SOCKET)
> Derived type: (FUNCTION (&REST T) *)
> Perform the accept(2) call, returning a
> newly-created connected socket and the peer address as multiple
> Method-combination: STANDARD
> (SOCKET-ACCEPT (SB-BSD-SOCKETS:SOCKET))
> Source file: SYS:SRC;PCL;DFUN.LISP.NEWEST
> Which had no mention of the port.
> As for socket-getpeername, it's best to use this when the socket is
> supplied by another source such as inetd; accept(2) is designed to
> already return the necessary information to avoid another syscall.
> Since you confirm that SBCL actually now does this, I can in turn
> confirm to the ECL maintainer that it's safe to commit my diff without
> breaking SBCL compatibility, and I'm happy :)
> Thanks a lot,
> Got Input? Slashdot Needs You.
> Take our quick survey online. Come on, we don't ask for help often.
> Plus, you'll get a chance to win $100 to spend on ThinkGeek.
> Sbcl-devel mailing list