Chinaunix首页 | 论坛 | 博客
  • 博客访问: 541018
  • 博文数量: 493
  • 博客积分: 2891
  • 博客等级: 少校
  • 技术积分: 4960
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-17 17:11
文章分类

全部博文(493)

文章存档

2010年(493)

分类:

2010-05-12 19:39:09

int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
// poll is a variation on the theme of select.  It specifies an array of nfds structures of type
//
  struct pollfd {
                       int fd;           /* file descriptor */
                       short events;     /* requested events */
                       short revents;    /* returned events */
               };           
//具体用法在linux命令下执行man poll,可以看到poll详细信息。
4 经验总结:预防措施和规范建议
使用系统API以及外部库的时候,需要了解其使用的限制。不清楚这些限制的时候,服务运行时会出现一些非期望的错误。
 定位问题时,可以大胆怀疑,然后单独构造场景验证自己的想法。单独构造场景可以排出其他原因引入的干扰,尽快收敛问题。
5 备注
具体用法在linux命令下执行man poll,可以看到poll详细信息.有兴趣的可以在linux上查阅一下
6 考核点
文件描述符, 溢出
7 试题
int main(int argc, char* argv[])
{
    int a = 1; // sockset之前的内存区
    int b = 2; // sockset之前的内存区
    char sock[1024];
    int c = 3;
    int d = 4;
    memset(sock,0,sizeof(sock));
    sock[1024] = '\0';
printf("a=%d, b=%d, c=%d,d=%d",a,b,c,d);

在windows执行上面程序, 下面正确的说法是(D)
A,、屏幕上输出 a=1, b=2, c=3,d=4
B、屏幕上输出,a=1, b=2, c=0,d=4
C、输出界面一定抛出异常
D、上述说法均不正确
阅读(369) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~