gpt4 book ai didi

Haskell 将套接字绑定(bind)到特定 IP

转载 作者:行者123 更新时间:2023-12-01 04:04:12 25 4
gpt4 key购买 nike

在 Haskell network包裹
bindSocket使用 HostAddressHostAddress6
定义为:

-- | Network byte order.
type HostAddress = Word32

-- | Host byte order.
type HostAddress6 = (Word32, Word32, Word32, Word32)
  • 我怎样才能从 123.123.123.123Word32 ?
  • 我怎样才能从 IPv6字符串到 (Word32, Word32, Word32, Word32) ?
  • 字节序是否在不同的操作系统(Windows、Linux、OS X、FreeBSD)上起作用?
  • 最佳答案

    使用 getAddrInfo :

    getAddrInfo :: Maybe AddrInfo -> Maybe HostName -> Maybe ServiceName -> IO [AddrInfo]   

    Resolve a host or service name to one or more addresses. The AddrInfo values that this function returns contain SockAddr values that you can pass directly to connect or bindSocket.

    This function is protocol independent. It can return both IPv4 and IPv6 address information.

    关于Haskell 将套接字绑定(bind)到特定 IP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10659637/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com