Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3217190
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:22:56+00:00 2026-05-17T15:22:56+00:00

Can’t see why this is happening, but when I use Bluetooth to send data

  • 0

Can’t see why this is happening, but when I use Bluetooth to send data to connected peers, they receive the data perfectly well but then immediately disconnect making further interaction impossible. Can anyone give any indication as to why this might be happening? I tried changing the timeout to 60 seconds, I tried reducing the amount of data sent to less than 500 bytes, and still I get this strange situation where peers will immediately disconnect from one another. Is it maybe because I’m using a GKSession to initialise the network, then a GKPeerPicker for people to connect to it?

Here’s my data sending-and-receiving code. This is mostly temporary and will probably change to accommodate large amounts of data, but right now I just want to establish a stable connection.

-(void)transmitWholeClusterToPeer:(NSString *)peerID{
NSMutableData *data = [NSMutableData data];
NSKeyedArchiver *encoder = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data];

[encoder encodeInt:0 forKey:@"Mode"];
[encoder encodeObject:clusterMap.header forKey:@"Header"];
[encoder finishEncoding];

NSArray *peerList = [[[NSArray alloc] initWithObjects:peerID, nil] copy];

[network sendData:data toPeers:peerList withDataMode:GKSendDataReliable error:nil];
[encoder autorelease];      
[peerList autorelease];

}

-(void)receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session
       context:(void *)context{
NSKeyedUnarchiver *decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
int mode = [decoder decodeIntForKey:@"Mode"];

switch (mode) {
    case 0:
        clusterMap.header = [decoder decodeObjectForKey:@"Header"];
        break;
    default:
        break;
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:22:57+00:00Added an answer on May 17, 2026 at 3:22 pm

    I can’t say for sure this is the definitive answer, but I have solved the problem after a fashion by removing GKPeerPicker and implementing my own Client-Server setup code that generates ‘keep alive’ pings itself. I think the problem really was only that I was setting up a session manually, then using the Peer Picker to connect to it. It seems that Peer Pickers are only stable and useful when they are connecting to other Peer Pickers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can find why i get this error can someone help? package Android.data; public class
Can anyone explain to me why this program: for(float i = -1; i <
Can someone maybe tell me why this is not working? I have used echo
Can anybody tell me a regular expression to use within some PHP to find
Can I continue to use the interbase vcl components in delphi 2010 with firebird
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Can I use inheritance mapping in AutoMapper (v2.2) for maps with the same Source
Can i use highlighter class to highlight the all occurrences of a word in
Can someone post or point out an example of how flat-file data access is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.