QuicSocketAccept函数 返回一个套接字

QuicSocket newSocket = QuicSocketAccept(fd);

跟踪这个函数

QuicSocket QuicSocketAccept(QuicSocket listenSock)
{
//判断传入的值auto socket = EntryBase::GetFdManager().Get(listenSock);if (!socket || socket->Category() != EntryCategory::Socket) {DebugPrint(dbg_api, "sock = %d, return = -1, errno = EBADF", listenSock);errno = EBADF;return -1;}
//重点是这个AcceptSocket函数 返回一个整数auto newSocket = ((QuicSocketEntry*)socket.get())->AcceptSocket();if (!newSocket) {DebugPrint(dbg_api, "sock = %d, return = -1, errno = %d", listenSock, errno);return -1;}DebugPrint(dbg_api, "sock = %d, newSocket = %d", listenSock, newSocket->Fd());return newSocket->Fd();
}

//跟踪一下这个AcceptSocket函数

QuicSocketEntryPtr QuicSocketEntry::AcceptSocket()
{
//还是先判断一下状态if (socketState_ != QuicSocketState_Binded) {errno = EINVAL;return QuicSocketEntryPtr();}std::unique_lock<std::mutex> lock(acceptSocketsMtx_);if (acceptSockets_.empty()) {//判断是否为空errno = EAGAIN;return QuicSocketEntryPtr();}auto ptr = acceptSockets_.front();//返回这个列表的第一个元素acceptSockets_.pop_front();return ptr;
}

auto ptr = acceptSockets_.front();//返回这个列表的第一个元素

//返回这个列表的第一个元素// element access/***  Returns a read/write reference to the data at the first*  element of the %list.*/referencefront() _GLIBCXX_NOEXCEPT{ return *begin(); }/***  Returns a read-only (constant) reference to the data at the first*  element of the %list.*/const_referencefront() const _GLIBCXX_NOEXCEPT{ return *begin(); }

acceptSockets_.pop_front();

 /***  @brief  Removes first element.**  This is a typical stack operation.  It shrinks the %list by*  one.  Due to the nature of a %list this operation can be done*  in constant time, and only invalidates iterators/references to*  the element being removed.**  Note that no data is returned, and if the first element's data*  is needed, it should be retrieved before pop_front() is*  called.*/voidpop_front() _GLIBCXX_NOEXCEPT{ this->_M_erase(begin()); }/***  @brief  Add data to the end of the %list.*  @param  __x  Data to be added.**  This is a typical stack operation.  The function creates an*  element at the end of the %list and assigns the given data to*  it.  Due to the nature of a %list this operation can be done*  in constant time, and does not invalidate iterators and*  references.*/voidpush_back(const value_type& __x){ this->_M_insert(end(), __x); }
类似于出栈操作

posix_qui-master 服务器端QuicAccept()函数相关推荐

  1. 【Java 网络编程】TCP 服务器端 客户端 简单示例

    文章目录 I IntelliJ IDEA 创建 Java 项目 II 客户端 Socket 创建 III Socket 客户端连接服务器端 IV Socket 两个端点信息获取 V 控制台人机交互 V ...

  2. PL/SQL -- 函数

    --================== -- PL/SQL --> 函数 --================== 函数通常用于返回特定的数据.其实质是一个有名字的PL/SQL块,作为一个sc ...

  3. DataTables—服务器端翻页

    2019独角兽企业重金招聘Python工程师标准>>> 本文是jquery<--json-->spring(3.0)系列的第三篇. 原文地址:http://blog.cs ...

  4. 网络编程函数小总结与初识socket

    总结服务器端的函数和客户端的函数 再次声明博主写的都是对于linux下的网络编程,没有写关于Windows的网络编程,也许以后会写到. 这里只是总结一下,具体参数的含义等后面的跟新 1. #inclu ...

  5. 找不到列 dbo 或用户定义的函数或聚合 dbo xxx ,或者名称不明确

    MSSQL执行查询错误提示:找不到列 "dbo" 或用户定义的函数或聚合 "dbo.xxx",或者名称不明确. 错误原因及解决办法: 原因1:数据库中不存在这个 ...

  6. FPGA开发技巧备忘录——Xilinx JTAG to AXI Master IP的使用

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 FPGA开发技巧备忘录--Xilinx JTAG to AXI Master IP的使用 前言 用法 Tcl指令 展望 前言 无意间发 ...

  7. 箭头函数的this指向

    这里先明确一点:箭头函数的 this 指向比较特殊,它总是指向其最近的外层函数作用域的 this 所指对象 箭头函数 箭头函数为以下形式的函数 const func = (paramList) =&g ...

  8. 与socket网络编程有关的函数

    以下内容源于网络资源的学习与整理,如有侵权请告知删除. 基于TCP通信的服务模式 服务端 socket函数,获取网络连接的文件描述符 bind函数,将服务器的端口.ip地址与socket函数创建的文件 ...

  9. 17Web服务器端控件

    Web服务器端控件 Web服务器端控件 ASP.Net提供了两类服务器端控件:Html服务器端控件和Web服务器端控件.由于Web服务器端控件功能更强大,和Windows应用程序的控件使用方法类似,容 ...

最新文章

  1. 如何设置不一样的奇偶页页眉?
  2. springboot下Static变量通过@Value和set方法注入失败的问题和解决办法
  3. 【Linux】一步一步学Linux——sum命令(234)
  4. php htaccess实现缓存,使用.htaccess进行浏览器图片文件缓存,_PHP教程
  5. debian下tomcat8环境搭建
  6. 浮点数:一种有漏洞的抽象【译】
  7. HCIE-Security Day33:IPSec:深入学习ipsec ikev2、IKEV1和IKEV2比较
  8. 给你个选择Mac的理由,浅谈Macos系统的优点
  9. pve 虚拟环境 vi/vim不能右键粘贴设置方法
  10. Unity 使用Shader实现序列帧动画
  11. 天堂2地点坐标(SQL语句,可直接导入数据库)
  12. 资源---vc++2010学习版---注册码(注册码密匙)
  13. win2003企业版sp2序列号
  14. JavaScript 验证码制作
  15. python调用谷歌地图_使用Python调用谷歌地图并记录运动轨迹进行可视化
  16. azure创建centos_如何使用Blazor和Azure计算机视觉创建光学字符读取器
  17. webpack配置指定文件不打包
  18. 《盗梦空间》完全解析
  19. 大量精品中医古籍下载
  20. FPGA实现CAN通信CRC校验

热门文章

  1. 2017计算机应用期末考核,2017年秋季计算机应用基础期末考核作业.pdf
  2. CentOS下nohup命令
  3. 从苏宁电器到卡巴斯基(第二部)第11篇:我在卡巴的日子 XI
  4. 珠心算测验 【暴力】
  5. All work and no play makes jack a dull boy 中谓语为什么用makes
  6. python创建临时文件
  7. 河源食品安全检测实验室建设细节剖析
  8. Unity插件ShaderForge新版(2)
  9. 【思想感悟】人生就是一场直播
  10. 网络安全自学笔记+学习路线(超详细)