Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
IOS套接字编程、写入错误、文件描述符错误_Ios_Sockets - Fatal编程技术网

IOS套接字编程、写入错误、文件描述符错误

IOS套接字编程、写入错误、文件描述符错误,ios,sockets,Ios,Sockets,我正在使用CFStreamCreatePairWithSocketToHost创建一个输入和输出流到我的服务器。我使用scheduleinrunlop来处理这些流的事件。两个流都发送EventOpenCompleted消息。当我尝试在HasSpaceAvailable事件上写入流时,输出流给我错误代码9,“操作无法完成。文件描述符错误” 有没有人能通过socket communication使用ipad。我正在用ios5在ipad模拟器上测试这个 谢谢 Gerry你能分享你的源代码片段吗?当我试

我正在使用CFStreamCreatePairWithSocketToHost创建一个输入和输出流到我的服务器。我使用scheduleinrunlop来处理这些流的事件。两个流都发送EventOpenCompleted消息。当我尝试在HasSpaceAvailable事件上写入流时,输出流给我错误代码9,“操作无法完成。文件描述符错误”

有没有人能通过socket communication使用ipad。我正在用ios5在ipad模拟器上测试这个

谢谢
Gerry

你能分享你的源代码片段吗?当我试图复制我的代码时,注释空间太长:NSURL*website=[[NSURL URLWithString:server]retain];CFReadStreamRef readStream;CFWriteStreamRef writeStream;CFStreamCreatePairWithSocketToHost(NULL,(CFStringRef)[网站主机]、80、&readStream、&writeStream);inputStream=(NSInputStream*)readStream;outputStream=(NSOutputStream*)writeStream;[inputStream setDelegate:self];[outputStream setDelegate:self];[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop]forMode:NSDefaultRunLoopMode];[outputStream ScheduleRunLoop:[NSRunLoop currentRunLoop]forMode:NSDefaultRunLoopMode];[输入流打开];[输出流打开];抱歉格式化,这是我的连接代码。然后我尝试使用:case nsstreameventhassspaceavailable:if(theStream==outputStream){ev=@“有空间”;uint8_t*readBytes=(uint8_t*)[outputData mutableBytes];readBytes+=byteIndex;//移动指针int-data的实例变量[outputData leng=[outputData length];len=((data_len-byteIndex>=1024)?1024:(数据字节索引));if(len>0){uint8_t buf[len];(void)memcpy(buf,readBytes,len);int olen=[outputStream write:(const uint8_t*)buf maxLength:len];找到解决方案了吗?(要添加代码,只需编辑您的问题。)