chickadee » socket » socket-bind

socket-bind so saddrprocedure

Binds socket so to socket address saddr. The return value is unspecified.

; Bind to the IPv4 unspecified address on port 8000.
(define so (socket af/inet sock/stream))
(socket-bind so (inet-address "0.0.0.0" 8000))
; Bind to the IPv6 unspecified address on port 8000.  This may also
; allow IPv4 connections, depending on your system settings. 
(define so (socket af/inet6 sock/stream))
(socket-bind so (inet-address "::" 8000))
; Bind to the IPv6 unspecified address on port 8000, limiting
; connections to IPv6 only.
(define so (socket af/inet6 sock/stream))
(set! (ipv6-v6-only? so) #t)
(socket-bind so (inet-address "::" 8000))