微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ENet UDP开发包

程序名称:ENet

授权协议: 未知

操作系统: 跨平台

开发语言: C/C++

ENet 介绍

ENet 是一个易用的、可移植的 UDP 网络开发包,主要功能包括连接管理、可靠的按顺序的多通道包传输机制、包分解和重新打包、避免堵塞机制等。

下面是一个用 ENet 创建的服务器端代码示例:

    ENetAddress address;  
    ENetHost * server;

    /* Bind the server to the default localhost.     */  
    /* A specific host address can be specified by   */  
    /* enet_address_set_host (& address, "x.x.x.x"); */

    address.host = ENET_HOST_ANY;  
    /* Bind the server to port 1234. */  
    address.port = 1234;

    server = enet_host_create (& address /* the address to bind the server host to */,   
                                 32      /* allow up to 32 clients and/or outgoing connections */,  
                                  0      /* assume any amount of incoming bandwidth */,  
                                  0      /* assume any amount of outgoing bandwidth */);  
    if (server == NULL)  
    {  
        fprintf (stderr,   
                 "An error occurred while trying to create an ENet server host.\n");  
        exit (EXIT_FAILURE);  
    }  
    ...  
    ...  
    ...  
    enet_host_destroy(server);

ENet 官网

http://enet.bespin.org/

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐