问题描述
解决方案
iOS 网络编程 GCDasynsocket socket 发送数据
iOS 网络编程 socket 发送数据
iOS开发ASIHttpRequest发送数据
解决方案二:
http://www.cocoachina.com/bbs/read.php?tid-331258.html
来这里看到一样的,同一个人问的吧。哈哈哈
解决方案三:
用C的方法封装,然后转NSData
解决方案四:
sendB = 0xa0;
int flen = sendData.length;
int blen = (sendData.length % 14) == 0 ? (sendData.length / 14) : (sendData.length / 14 + 1);
UInt8 fb[4] = {0};
fb[3] = (Byte)(flen >> 0);
fb[2] = (Byte)(flen >> 8);
fb[1] = (Byte)(flen >> 16);
fb[0] = (Byte)(flen >> 24);
UInt8 bb[4] = {0};
bb[3] = (Byte)(blen >> 0);
bb[2] = (Byte)(blen >> 8);
bb[1] = (Byte)(blen >> 16);
bb[0] = (Byte)(blen >> 24);
UInt8 xval[14]={0};
xval[0] = 0x80;
xval[1] = 0x0b;
xval[3] = 0xa0;
xval[4] = fb[2];
xval[5] = fb[3];
xval[6] = bb[2];
xval[7] = bb[3];
// xval[8] = 0x00;//文件序号
// xval[9] = 0x01;
filenameA = fb[3];
filenameB = fb[2];
xval[8] = filenameA;
xval[9] = filenameB;
xval[10] = fileExtend >> 8;//文件类型
xval[11] = fileExtend >> 0;
xval[12] = 0x00;//保留字
xval[13] = fileFolder;
xval[2] = xval[3]^xval[4]^xval[5]^xval[6]^xval[7]^xval[8]^xval[9]^xval[10]^xval[11]^xval[12]^xval[13];//效验
NSData *fd = [[NSData alloc] initWithBytes:&xval length:14];
时间: 2024-09-15 03:30:27