Objective-c - How does the iOS client send pictures to the Java server through GCDAsyncSocket?
PHP中文网
PHP中文网 2017-05-02 09:31:48
0
0
663

How does the iOS client send pictures to the Java server through GCDAsyncSocket?
The java server said to send it three times, the first time it sent the file name (utf), the second time it sent the file length (int), and the third time it sent the picture (bytes)
This is the code I also need, but The server can't receive my pictures? ?

             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中文网
PHP中文网

认证高级PHP讲师

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template