का उपयोग कर धीमी फ़ाइल स्थानांतरण IOS 7 के मल्टीपायर कनेक्टिविटी फ्रेमवर्क का उपयोग करके दो डिवाइसों के बीच एक फ़ाइल भेज रहा हूं। मैं फ़ाइल को ट्रांफर करने के लिए एनएसएसटीम्स का उपयोग कर रहा हूं, एमसीएसशन के प्रेषण डेटा का उपयोग करने के अपने पिछले प्रयास के रूप में: toPeers: withMode वास्तव में अविश्वसनीय था। दुर्भाग्य से मुझे जो स्थानांतरण गति मिल रही है वह वास्तव में धीमी है, लगभग 100 किलोग्राम/एस, जो उस एप्लिकेशन के लिए काम नहीं करेगी जिस पर मैं काम कर रहा हूं। यहां मेरे इनपुट और आउटपुट स्ट्रीम प्रतिनिधि विधियां हैं, जहां फ़ाइल स्थानांतरण होता है।मल्टीपायर कनेक्टिविटी फ्रेमवर्क
आउटपुट स्ट्रीम
...//previous code
case NSStreamEventHasSpaceAvailable: {
//we will only open the stream when we want to send the file.
NSLog(@"Stream has space available");
//[self updateStatus:@"Sending"];
// If we don't have any data buffered, go read the next chunk of data.
if (totalBytesWritten< outgoingDataBuffer.length) {
//more stuff to read
int towrite;
int diff = outgoingDataBuffer.length-packetSize;
if (diff <= totalBytesWritten)
{
towrite = outgoingDataBuffer.length - totalBytesWritten;
} else
towrite = packetSize;
NSRange byteRange = {totalBytesWritten, towrite};
uint8_t buffer[towrite];
[outgoingDataBuffer getBytes:buffer range:byteRange];
NSInteger bytesWritten = [outputStream write:buffer maxLength:towrite];
totalBytesWritten += bytesWritten;
NSLog(@"Written %d out of %d bytes",totalBytesWritten, outgoingDataBuffer.length);
} else {
//we've written all we can write about the topic?
NSLog(@"Written %d out of %d bytes",totalBytesWritten, outgoingDataBuffer.length);
[self endStream];
}
// If we're not out of data completely, send the next chunk.
} break;
इनपुट स्ट्रीम (स्ट्रीम के लिए प्रतिनिधि में)
- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {
switch(eventCode) {
case NSStreamEventHasBytesAvailable:
{
NSLog(@"Bytes Available");
//Sent when the input stream has bytes to read, we need to read bytes or else this wont be called again
//when this happens... we want to read as many bytes as we can
uint8_t buffer[1024];
int bytesRead;
bytesRead = [inputStream read:buffer maxLength:sizeof(buffer)];
[incomingDataBuffer appendBytes:&buffer length:bytesRead];
totalBytesRead += bytesRead;
NSLog(@"Read %d bytes, total read bytes: %d",bytesRead, totalBytesRead);
}break;
case NSStreamEventEndEncountered:
{
UIImage *newImage = [[UIImage alloc]initWithData:incomingDataBuffer];
[[self.detailViewController imageView] setImage:newImage];
NSLog(@"End Encountered");
[self closeStream];
//this should get called when there aren't any more bytes being sent down the stream
}
}
}
वहाँ या तो बहु सूत्रण या एक थोड़ा संशोधित NSStream उपवर्ग का उपयोग कर के माध्यम से इस फ़ाइल स्थानांतरण तेजी लाने के लिए एक रास्ता है जो एसिंक्रोनस सॉकेट का उपयोग करता है?
क्या आप अभी भी साथियों के लिए ब्राउज़ कर रहे हैं? यह आलेख (http://mzsanford.com/blog/ios7-multipeer-wifi-slow/index.html) इस बारे में बात करता है कि ब्राउज़िंग/विज्ञापन आपके समग्र वाईफाई प्रदर्शन को कैसे प्रभावित कर सकता है। साथ ही, क्या आपके पास यह डिवाइस डिवाइस से सिम्युलेटर पर जा रहा है? मैं सिम से डिवाइस पर जा सकता हूं, लेकिन जब मैं सिम को भेजने की कोशिश करता हूं तो मेरी इनपुट स्ट्रीम एक बार डेटा पढ़ने का प्रयास करती है और इसे शून्य डेटा मिल जाता है तो यह डिस्कनेक्ट हो जाता है। – Brian
हे ब्रायन। मेरे सेटअप में दो आईपैड मिनी के फ़ाइल स्थानांतरण को निष्पादित करने वाले अलग-अलग अनुप्रयोग चल रहे हैं। ब्राउज़र और विज्ञापनदाता कनेक्ट होने के बाद भी मैं सहकर्मियों के लिए ब्राउज़ कर रहा हूं क्योंकि जब मैं साथियों के लिए ब्राउज़ करना बंद करता हूं तो मैं डिवाइस से कनेक्शन खो देता हूं। SendData: toPeers विधि का उपयोग करते समय मैं लगातार डिस्कनेक्शन के साथ समान मुद्दों में भाग रहा था। यही कारण है कि मैंने स्ट्रीम विधियों का उपयोग करने के लिए स्विच किया। –
यह सिर्फ अजीब है क्योंकि डिवाइस से डिवाइस तक एयर ड्रॉप इतनी तेज़ी से काम करता है, लेकिन फ़ाइल स्थानांतरण निष्पादित करना वास्तव में धीमा है। ऐप्पल अपने स्वयं के कार्यान्वयन के लिए दृश्यों के पीछे कुछ कर रहा होगा। –