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];