udp协议下sendto与recvfrom函数对应的errno

本文介绍了在C/C++中使用UDP套接字时,sendto和recvfrom函数可能遇到的不同errno。在JavaScript中,这两个操作的错误会被统一通过特定事件抛出,因此列出它们的errno有助于在JavaScript中进行错误处理。
部署运行你感兴趣的模型镜像

概述

在C/C++中,使用udp socket时,sendtorecvfrom 有不同的errno

而在高阶语言Javascript中,使用udp socket, 会将两种类型的错误通过同一个事件 error 抛出来

因此,有必要将 sendtorecvfrom 对应的 errno列出来,以便在error中进行区分

var code = “a9fb4b37-0ec1-447e-b8f9-46ea94ea0880”

内容

sendto()失败时,有如下的错误码:

errnoerrmsg
[EAFNOSUPPORT]Addresses in the specified address family cannot be used with this socket.
[EAGAIN] or [EWOULDBLOCK]The socket’s file descriptor is marked O_NONBLOCK and the requested operation would block.
[EBADF]The socket argument is not a valid file descriptor.
[ECONNRESET]A connection was forcibly closed by a peer.
[EINTR]A signal interrupted sendto() before any data was transmitted.
[EMSGSIZE]The message is too large to be sent all at once, as the socket requires.
[ENOTCONN]The socket is connection-mode but is not connected.
[ENOTSOCK]The socket argument does not refer to a socket.
[EOPNOTSUPP]The socket argument is associated with a socket that does not support one or more of the values set in flags.
[EPIPE]The socket is shut down for writing, or the socket is connection-mode and is no longer connected. In the latter case, and if the socket is of type SOCK_STREAM or SOCK_SEQPACKET and the MSG_NOSIGNAL flag is not set, the SIGPIPE signal is generated to the calling thread.
[EIO]An I/O error occurred while reading from or writing to the file system.
[ELOOP]A loop exists in symbolic links encountered during resolution of the pathname in the socket address.
[ENAMETOOLONG]The length of a component of a pathname is longer than {NAME_MAX}.
[ENOENT]A component of the pathname does not name an existing file or the pathname is an empty string.
[ENOTDIR]A component of the path prefix of the pathname in the socket address names an existing file that is neither a directory nor a symbolic link to a directory, or the pathname in the socket address contains at least one non- slash character and ends with one or more trailing slash characters and the last pathname component names an existing file that is neither a directory nor a symbolic link to a directory.
[EACCES]Search permission is denied for a component of the path prefix; or write access to the named socket is denied.
[EDESTADDRREQ]The socket is not connection-mode and does not have its peer address set, and no destination address was specified.
[EHOSTUNREACH]The destination host cannot be reached (probably because the host is down or a remote router cannot reach it).
[EINVAL]The dest_len argument is not a valid length for the address family.
[EISCONN]A destination address was specified and the socket is already connected.
[ENETDOWN]The local network interface used to reach the destination is down.
[ENETUNREACH]No route to the network is present.
[ENOBUFS]Insufficient resources were available in the system to perform the operation.
[ENOMEM]Insufficient memory was available to fulfill the request.

recvfrom()失败时,有如下的错误码:

errnoerrmsg
[EAGAIN] or [EWOULDBLOCK]The socket’s file descriptor is marked O_NONBLOCK and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the socket’s file descriptor is marked O_NONBLOCK or the socket does not support blocking to await out-of-band data.
[EBADF]The socket argument is not a valid file descriptor.
[ECONNRESET]A connection was forcibly closed by a peer.
[EINTR]A signal interrupted recvfrom() before any data was available.
[EINVAL]The MSG_OOB flag is set and no out-of-band data is available.
[ENOTCONN]A receive is attempted on a connection-mode socket that is not connected.
[ENOTSOCK]The socket argument does not refer to a socket.
[EOPNOTSUPP]The specified flags are not supported for this socket type.
[ETIMEDOUT]The connection timed out during connection establishment, or due to a transmission timeout on active connection.
[EIO]An I/O error occurred while reading from or writing to the file system.
[ENOBUFS]Insufficient resources were available in the system to perform the operation.
[ENOMEM]Insufficient memory was available to fulfill the request.

参考资料

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值