iOS客户端如何 通过GCDAsyncSocket给Java服务器发送图片?
java服务器说发三次,第一次发文件明名(utf),第二次发文件长度(int),第三次发图片(字节)
这是我也得代码,但是服务器收不到我的图片??
NSData *data = UIImageJPEGRepresentation(result, 0.1);
[self createClientTcpSocket];
NSData *nameDate = [@"图片名2.jpg" dataUsingEncoding:NSUTF8StringEncoding];
[asyncsocket writeData:nameDate withTimeout:-1 tag:0];
uint64_t length =(uint64_t) data.length;
length = CFSwapInt64HostToBig(length);
NSData *lengthdata = [NSData dataWithBytes:&length length:8];
[asyncsocket writeData:lengthdata withTimeout:-1 tag:0];
[asyncsocket writeData:data withTimeout:-1 tag:0];
[asyncsocket readDataWithTimeout:-1 tag:0];
认证高级PHP讲师