红联Linux门户
Linux帮助

TCP/IP和套接口编程

发布时间:2008-07-09 14:49:58来源:红联作者:linlangshu
程序server.c
..........
bzero(&sin,sizeof(sin));
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = htons(port);

...........
这段程序何解

我的理解是

bzero(&sin,sizeof(sin)); --清空一块区域
sin.sin_family = AF_INET; --sin的协议是AF_INET
sin.sin_addr.s_addr = INADDR_ANY;--IP地址是INADDR_ANY,任何一个地址都可以
sin.sin_port = htons(port);--端口号

我的理解对吗

[ 本帖最后由 linlangshu 于 2008-7-9 14:52 编辑 ]
文章评论

共有 7 条评论

  1. taotie 于 2008-08-01 09:18:00发表:

    5:ty( 5:ty(

  2. taotie 于 2008-08-01 09:17:48发表:

    :0wmjh(1 :0wmjh(1

  3. taotie 于 2008-08-01 09:17:44发表:

    :0w5ty(1 :0w5ty(1 :0w5ty(1

  4. taotie 于 2008-08-01 09:15:32发表:

    :0wmjh(1 :0wmjh(1 :0wmjh(1

  5. resun432 于 2008-07-11 13:59:43发表:

    :0w5ty(1

  6. gongji110 于 2008-07-10 10:51:05发表:

    初始化套接字

  7. linlangshu 于 2008-07-09 15:29:35发表:

    Client.c
    .......
    bzero(&pin, sizeof(pin));
    pin.sin_family = AF_INET;
    pin,sin_addr.s_addr = hton1(INADDR_ANY);
    pin.sin_addr.s_addr = ((struct in_addr *)(server_host_name>h_addr)) > s_addr;
    pin.sin_port = htons(port);
    ......


    这段怎么理解