xinghelee
V2EX  ›  C

iOS Socket 建立连接后,如何获取本机( iPhone )所使用的端口?

  •  
  •   xinghelee · Dec 23, 2016 · 2903 views
    This topic created in 3624 days ago, the information mentioned may be changed or developed.
    1 replies  •  2017-02-07 21:47:46 +08:00
    banxi1988
    banxi1988
    Feb 7, 2017
    1
    有这么一个系统函数可供使用:
    getsockname

    #include <sys/socket.h>
    int
    getsockname(int socket, struct sockaddr *restrict address,
    socklen_t *restrict address_len);

    详情见参考相关手册或文档. 地址及端口信息在 sockaddr 中.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2291 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 13:26 · PVG 21:26 · LAX 05:26 · JFK 08:26
    ♥ Do have faith in what you're doing.