在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. Unity Transform

    public class PlayerControll : MonoBehaviour { Transform playerTransform; Animation playerAnimation; ...

  2. pacman usage

    pacman使用 安装了系统时候, 应该立马使用pacman-mirrors -c China更新源, 再使用pacman -Syyn更新系统 编辑/etc/pacman.conf添加 [archli ...

  3. NodeJS 开发应用

    NodeJS 开发应用 使用的 Node 版本: V8.11.4 开发工具: VSCode 1.27.1 系统: Deepin 15.7 Desktop x64 项目结构 项目结构 Project i ...

  4. Unity C# 使用JsonUtility读写Json文件

    本文原创,转载请注明出处:http://www.cnblogs.com/AdvancePikachu/p/7146731.html 今天,为大家分享一下unity上的Json序列化,应该一说到这个词语 ...

  5. 在CentOS上配置tomcat服务

    # hapday start 2016-02-04 #!/bin/bash # description: Tomcat Start Stop Restart # processname: tomcat ...

  6. HTML标签_1

    <meta charset="utf-8" /> 设置字符集 <meta name="description" content="这 ...

  7. dojo事件绑定

    Dojo如何动态绑定事件的小demo <html> <title>事件绑定测试test</title> <head></head> < ...

  8. 【QT】【OpenCv】初始配置以及测试功能

    #include "mainwindow.h" #include "ui_mainwindow.h" #include<opencv2/core/core ...

  9. rollback

    savepoint test; rollback to savepoint test;

  10. tfs2012安装

    今天正在配置tfs的服务器.要先安装net 3.5 ps1.要选择安装reportingservers 来启动报表功能.