gpt4 book ai didi

ios - 发布/临时构建失败但在 Debug模式下工作(ios)

转载 作者:行者123 更新时间:2023-11-28 17:40:13 25 4
gpt4 key购买 nike

使用 TCP 套接字在后台模式 (ios) 中运行示例应用程序。当客户端发送任何消息并等待另一条消息时,它会给出消息(本地通知)。当应用程序在调试中运行时它工作正常,但在发布时崩溃10 秒后模式。使用:用于测试的 xcode 4.2 和 iPad 2..

这是我正在使用的代码:

 struct sockaddr_in serv_addr, cli_addr;

CFReadStreamRef hReadStream;

sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) printf("Sockfd Error\n");

bzero((char *) &serv_addr, sizeof(serv_addr));
portNo = 3600;//atoi(argv);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(portNo);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
printf("bind error\n");



listen(sockfd,5);

clilen = sizeof(cli_addr);

newsockfd = 1;


while(newsockfd)
{

newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
NSLog(@"newsockfd create %d\n",newsockfd);

remoteAdd = inet_ntoa(cli_addr.sin_addr);

//cout << remoteAdd << " port = " << cli_addr.sin_port << endl;

portNo = cli_addr.sin_port;

#if defined(__IPHONE_4_0) && !(TARGET_IPHONE_SIMULATOR)

NSLog(@"newsocket %d\n",newsockfd);

// Only do this if it is a SipSocket we are watching
if (newsockfd)
{
// Set it to non-blocking
//int set = 0;
//ioctl(newsockfd, FIONBIO, reinterpret_cast<int>(&set));

CFStreamCreatePairWithSocket (kCFAllocatorDefault, newsockfd,
&hReadStream, NULL);
if (CFReadStreamSetProperty(hReadStream,
kCFStreamNetworkServiceType,
kCFStreamNetworkServiceTypeVoIP) != TRUE)
{
// An error occured, delete the stream
if(hReadStream != NULL)
{
CFReadStreamClose(hReadStream);
CFRelease(hReadStream);
hReadStream = NULL;
}

//return -1;
}
else NSLog(@" >>>>>>>>>>>>>>>>>>> property set Here <<<<<<<<<<<<<<<<\n");

if (CFReadStreamOpen(hReadStream) != TRUE)
{
// An error occured, delete the stream
if(hReadStream != NULL)
{
CFReadStreamClose(hReadStream);
CFRelease(hReadStream);
hReadStream = NULL;
}

// return -1;
}
else NSLog(@"read....\n");
}
#endif

[self test];
}

设备日志中的崩溃报告:

"Application 'Demo' exited abnormally with signal 9: Killed: 9" &
"unknown ReportCrash[10915] <Error>: Saved crashreport to
/var/mobile/Library/Logs/CrashReporter/servertest_2011-12-13-163920_EyeBalls-iPad.plist
using uid: 0 gid: 0, synthetic_euid: 501 egid: 0"

试图找到错误,但它在 Debug模式下工作正常在设备日志或调试窗口中完全没有发现错误..请帮助我:(

最佳答案

您可以将编译器选项切换为 llvm gcc4.2 。我猜这是与 clang 有关的问题。希望它能正常工作。

关于ios - 发布/临时构建失败但在 Debug模式下工作(ios),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8484828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com