zoukankan      html  css  js  c++  java
  • getsockname()/getpeername()函数第一次被调用得到0.0.0.0结果

    int getsockname(int sockfd, struct sockaddr *addr, socklen_t *addrlen);

    getsockname() returns the current address to which the socket sockfd is bound,in the buffer pointed to by addr. The addrlen argument should be initialized to indicate the amount of space (in bytes) pointed to by addr. On return it contains the actual size of the socket address.

    The returned address is truncated if the buffer provided is too small;  in  this case, addrlen will return a value greater than was supplied to the call.

    通过手册说明,可以看到addrlen参数所指的对象必须初始化,另外,如果初始提供的值太小,getsockname()函数在返回时,新写入addrlen指向的对象的值将会大于所调用时提供的值。

  • 相关阅读:
    C# using
    Spring框架
    is
    pycharm破解197
    python安装197
    python3.7.0安装197
    centos7 minimal 安装mysql197
    centos7 minimal 安装 &网络配置197
    ruby安装卸载197
    redis安装 卸载 启动 关闭197
  • 原文地址:https://www.cnblogs.com/kex1n/p/7881866.html
Copyright © 2011-2022 走看看