【FAQ】全志XR806芯片 getsockopt、setsockopt失败如何解决?
-
1. 问题背景
调用 setsockopt 设置 socket 属性失败,或者 getsockopt 获取 socket 属性失败。2. 问题描述
调用 setsockopt、getsockopt 时返回 -1,且 errno 为 ENOPROTOOPT(92)。3. 问题分析
LwIP 当前版本有部分 socket 属性的设置/获取是暂时没有支持的,操作这些属性会返回 errno = ENOPROTOOPT 的错误码。4. 解决办法
以 SDK 中 lwip-2.0.3 为例。可以通过打开文件 include/net/lwip-2.0.3/lwip/sockets.h 查看目前版本 LwIP 支持哪些 socket 属性的设置/获取。#define SO_DEBUG 0x0001 /* Unimplemented: turn on debugging info recording */ #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ #define SO_DONTROUTE 0x0010 /* Unimplemented: just use interface addresses */ #define SO_USELOOPBACK 0x0040 /* Unimplemented: bypass hardware when possible */ #define SO_LINGER 0x0080 /* linger on close if data present */ #define SO_DONTLINGER ((int)(~SO_LINGER)) #define SO_OOBINLINE 0x0100 /* Unimplemented: leave received OOB data in line */ #define SO_REUSEPORT 0x0200 /* Unimplemented: allow local address & port reuse */ #define SO_SNDBUF 0x1001 /* Unimplemented: send buffer size */ #define SO_RCVBUF 0x1002 /* receive buffer size */ #define SO_SNDLOWAT 0x1003 /* Unimplemented: send low-water mark */ #define SO_RCVLOWAT 0x1004 /* Unimplemented: receive low-water mark */ #define SO_SNDTIMEO 0x1005 /* send timeout */ #define SO_RCVTIMEO 0x1006 /* receive timeout */ #define SO_ERROR 0x1007 /* get error status and clear */ #define SO_TYPE 0x1008 /* get socket type */ #define SO_CONTIMEO 0x1009 /* Unimplemented: connect timeout */ #define SO_NO_CHECK 0x100a /* don't create UDP checksum */
如上所示,若该属性后的注释有 Unimplemented 标识,则未支持。
-
-
-
-
-
-
Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号