Bind this socket to an address, on port (to all addresses if null)

On error, sets error appropriately.

Property definitions

socket $ UDPSocket :: bind
	# Bind this socket to an `address`, on `port` (to all addresses if `null`)
	#
	# On error, sets `error` appropriately.
	fun bind(address: nullable Text, port: Int)
	do
		var addr_in = new NativeSocketAddrIn
		addr_in.port = port
		if address != null then
			# FIXME replace all use of gethostbyname with something not obsolete
			var hostent = sys.gethostbyname(address.to_cstring)
			if hostent.address_is_null then
				error = new IOError.from_h_errno
				addr_in.free
				return
			end

			addr_in.fill_from_hostent hostent
		else
			addr_in.family = new NativeSocketAddressFamilies.af_inet
			addr_in.address_any
		end

		if native.bind(addr_in) != 0 then error = new IOError.from_errno

		addr_in.free
	end
lib/socket/socket.nit:355,2--380,4