iphone设置非阻塞模式socket两种方法
2010-01-25 13:06
609 查看
1. ioctl()
2.fcntl()
/* set socket to non-blocking i/o */ sts = ioctl(ccp->main_sock, FIONBIO, (char *)&one); if (sts) { setproderr(PE_TCPERROR, GEL_FATAL); sprintf(line,"ioctl (main) failed - %s",strerror(errno)); tcpabort(); }
2.fcntl()
/* Set socket to non-blocking */ if ((flags = fcntl(sock_descriptor, F_GETFL, 0)) < 0) { /* Handle error */ } if (fcntl(socket_descriptor, F_SETFL, flags | O_NONBLOCK) < 0) { /* Handle error */ } /* Set socket to blocking */ if ((flags = fcntl(sock_descriptor, F_GETFL, 0)) < 0) { /* Handle error */ } if (fcntl(socket_descriptor, F_SETFL, flags & (~O_NONBLOCK)) < 0) { /* Handle error */ }
相关文章推荐
- iOS开发(iPad/iPhone)设置app界面 默认横向显示的两种方法
- 给iPhone联系人设置小头像的两种方法
- iOS开发(iPad/iPhone)设置app界面 默认横向显示的两种方法
- C# web api返回类型设置为json的两种方法
- jQuery 获取、设置HTML或TEXT内容的两种方法
- Socket编程实践(9) --套接字IO超时设置方法
- Android中两种设置全屏的方法
- iphone下bmp读取显示两种方法
- 设置Activity进入退出动画的两种方法
- Android基础教程之-------Android中两种设置全屏的方法
- Linux UDP socket 设置为的非阻塞模式与阻塞模式区别
- Kettle_设置变量的两种方法
- iPad和iPhone的app图标尺寸、用途、设置方法
- js设置控件的隐藏与显示的两种方法
- [转]设置textBox的响应按钮事件的js的两种方法
- IntelliJ IDEA使用技巧(四)——设置默认Maven的两种方法
- 判断iPhone的WiFi是否打开的两种方法 之是否连接上 WiFi
- Android高手进阶教程(八)-------Android中两种设置全屏的方法!!!
- 微信小程序 设置启动页面的两种方法
- Activity透明/半透明效果的设置transparent(两种实现方法)