Sockets have a phantom type parameter that tracks the state of the socket in order to eliminate certain errors in which socket functions are called in the wrong order. Initially, a socket is `Unconnected. As various socket functions are called, they return a socket with a new phantom state. Here is a chart of the allowed state transitions.
Unconnected ---connect--> Active | | ---bind--> Bound ---listen--> Passive ---accept---> Active | | ---connect--> Active
bind socket addr
sets close_on_exec for the fd of socket
.
bind_to_interface_exn t (`Interface_name "eth0")
restricts messages from being
received or sent on interfaces other than eth0
. See
Linux_ext.bind_to_interface.
Typically, one would use this function for very specific non-multicast requirements. For similar functionality when using multicast, see Core_unix.mcast_set_ifname.