现在的位置: 首页 > 综合 > 正文

linux下,accept得到的客户端地址为0.0.0.0:0的解决方法

2018年04月28日 ⁄ 综合 ⁄ 共 245字 ⁄ 字号 评论关闭

accept的第三个参数,在调用之前需要设置为第二个参数的长度。在manpage中有明确的说明:

 

       The addrlen argument is a value-result argument: the caller  must  ini‐
       tialize  it  to contain the size (in bytes) of the structure pointed to
       by addr; on return it will contain the actual size of the peer address.

抱歉!评论已关闭.