在app运行过程中按下home键或者其他原因app被挂起,socket连接不会断开,服务器为了节省资源,在一段时间后会主动关闭这个连接。当玩家再次切回到游戏后,前端并不知道这个连接已经断开了,继续通过断开的socket发送消息,这时候send函数会触发SIGPIPE异常导致程序崩溃。
 
解决这个问题我们需要在send的时候检测到服务器已经关闭连接,进行重新连接。正常情况下send函数返回-1表示发送失败,但是在IOS上SIGPIPE在send返回之前就终止了进程,所以我们需要忽略SIGPIPE,让send正常返回-1,然后重新连接服务器。
 
int set = 1;  
setsockopt(sd, SOL_SOCKET, SO_NOSIGPIPE, (void *)&set, sizeof(int)); 
 
参考转载:
http://i.cnblogs.com/EditPosts.aspx?opt=1
 
 
 

singnal 13 was raised的更多相关文章

  1. C# Development 13 Things Every C# Developer Should Know

    https://dzone.com/refcardz/csharp C#Development 13 Things Every C# Developer Should Know Written by ...

  2. Devexpress VCL Build v2013 vol 13.2.5 发布

    支持xe6 了,但是承诺的功能在哪里? What's New in 13.2.5 (VCL Product Line)   New Major Features in 13.2 What's New ...

  3. DevExpress VCL 13.1.2 发布

    DevExpress VCL 的2013 第一个公开版发布, 基本上就是一些维护,没有大的变化,也没有FM 的支持. What's New in DevExpress VCL 13.1.2   Rel ...

  4. TPO-19 C1 Discussing A Point Raised In A Lecture

    TPO-19 C1 Discussing A Point Raised In A Lecture 第 1 段 1.Listen to a conversation between a student ...

  5. ISO7816 (part 1-3) asynchronous smartcard information

    http://java.inf.elte.hu/java-1.3/javacard/iso7816.txt ============================================== ...

  6. Devexpress VCL Build v2013 vol 13.2.3 发布

    继续修修补补,大过年的,就不吐槽了. What's New in 13.2.3 (VCL Product Line)   New Major Features in 13.2 What's New i ...

  7. Devexpress VCL Build v2013 vol 13.2.2 发布

    devexpress 2013 的第二个大版本出来了,一如既往, 基本上还是一个大补丁包.各位看官,自己看. What's New in 13.2.2 (VCL Product Line)   New ...

  8. 13.5. zipfile — Work with ZIP archives

    13.5. zipfile — Work with ZIP archives Source code: Lib/zipfile.py The ZIP file format is a common a ...

  9. TechEmpower 13轮测试中的ASP.NET Core性能测试

    应用性能直接影响到托管服务的成本,因此公司在开发应用时需要格外注意应用所使用的Web框架,初创公司尤其如此.此外,糟糕的应用性能也会影响到用户体验,甚至会因此受到相关搜索引擎的降级处罚.在选择框架时, ...

随机推荐

  1. adb root错误信息adbd cannot run as root in production builds问题解决

    adb root错误信息adbd cannot run as root in production builds问题解决 一.问题描述 1.输入指令 >adb root adbd cannot ...

  2. Murano Weekly Meeting 2015.09.15

    Meeting time: 2015.September.15th 1:00~2:00 Chairperson:  Serg Melikyan, PTL from Mirantis Meeting s ...

  3. C语言测试int型数据的最大值最小值

    #include<stdio.h> int int_min(){    int i=0;    int j=0;    while(i>=j)    {        i=j;    ...

  4. php高级教程

    PHP - 多维数组 多维数组指的是包含一个或多个数组的数组. 注释:数组的维度指示您需要选择元素的索引数. 对于二维数组,您需要两个索引来选取元素 对于三维数组,您需要三个索引来选取元素 PHP - ...

  5. HDU 2389 ——Rain on your Parade——————【Hopcroft-Karp求最大匹配、sqrt(n)*e复杂度】

    Rain on your Parade Time Limit:3000MS     Memory Limit:165535KB     64bit IO Format:%I64d & %I64 ...

  6. CentOS 搭建Redis4 环境

    下载 wget http://download.redis.io/releases/redis-4.0.10.tar.gz   安装步骤 tar xvf redis-4.0.10.tar.gz mak ...

  7. grep和管道

    1.管道命令: 可以连接多个Linux命令 命令1 | 命令2 | 命令3 2.grep  正则表达式  从文件或者字符串中搜索字符串 格式:grep  ‘’  file 返回符合规则的行 需求:查询 ...

  8. checkBox 全选、全不选、反选

    checkBox的使用: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http: ...

  9. iOS重用宏定义

    iOS 多快好省的宏(转) 原文地址:http://my.oschina.net/yongbin45/blog/150149 // 字符串: #ifndef nilToEmpty #define ni ...

  10. js屏蔽鼠标操作

    document.body.onselectstart=document.body.oncontextmenu=function(){ return false;}