• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] Network connection between 2 iPhones
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] Network connection between 2 iPhones


  • Subject: Re: [iPhone] Network connection between 2 iPhones
  • From: Roland King <email@hidden>
  • Date: Tue, 14 Jul 2009 00:40:54 +0800

ok for that kind of generic data transfer I'd say the CFNetwork stuff is what you need, that's pretty low-level. There's NSStream too, but read the notes about the lack of NSHost stuff in iPhone. Effectively what you're aiming for here is to make a socket connection between the two and set the delegate to something in your code and schedule the stream into your runloop so you get called back when there is an update. Then you write to one stream and when data appears on the other one, you read it and process it.

You definitely need to read something about socket programming before heading down this path, it's tricky, sockets fail to connect, you need to be able to deal with totally asynchronous data. If you have a server in the middle you might want to think about just talking to that, one less connection to do (and your app then may scale to multiple data sources/sinks easier).

If there's a way to leave this until say later in your app development, whilst leaving hooks in the code for asynchronous 'from someone else' data, I'd possibly go that way.

On Jul 14, 2009, at 12:22 AM, James Lin wrote:

the usage scenario...

I want my app to obtain another iPhone(also running my app)'s IP address from a server.
After that, my app on my iPhone can send data to the other iPhone.
This means my app on another iPhone has to be waiting for this network traffic to arrive.


How can this be done?

Thank you again in advance...

James
On 2009/7/14, at 上午 12:11, Roland King wrote:

yes this really was rather too vague a question and if you don't have some of the basics of networking understood you're going to have a tough time. There are classes in the OS to deal with various types of network transfer, most of the NS* ones are reasonably high level, at the very bottom you have CFSocket which will do anything you like but needs an understanding of sockets. The GameKit APIs will let you have a quick bluetooth connection between two or more devices and is actually darned well designed for startup and teardown and quick opaque data transfer, if you want more generic client-server you have more work to do, including finding a method for telling device B what the IP address of device A is, that's tough.

Can you possibly narrow down what you're trying to do? Is it bluetooth (gamekit), is it internet? Do you have a central server to talk to, are you talking any high level protocols like HTTP which you can use the higher level APIs for or are you raw data on a socket?

On Jul 13, 2009, at 11:52 PM, I. Savant wrote:

On Jul 13, 2009, at 11:47 AM, James Lin wrote:

2. When my app is running...it can RECEIVE network data to ANOTHER
IPHONE through the network.

I'm going to assume this is a typo, otherwise you're going to have a difficult time achieving this goal. :-)


Can you please point me in the right direction?

Documentations to read? tutorials on the web? or please share your experience...

Since your question is general (I'm assuming you mean "how do I send and receive"), the answer is general as well:


http://developer.apple.com/iphone/library/navigation/Topics/NetworkingInternet/index.html

https://developer.apple.com/iphone/library/codinghowtos/NetworkingAndInternet/index.html

--
I.S.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >[iPhone] Network connection between 2 iPhones (From: James Lin <email@hidden>)
 >Re: [iPhone] Network connection between 2 iPhones (From: "I. Savant" <email@hidden>)
 >Re: [iPhone] Network connection between 2 iPhones (From: Roland King <email@hidden>)
 >Re: [iPhone] Network connection between 2 iPhones (From: James Lin <email@hidden>)

  • Prev by Date: Re: [iPhone] Network connection between 2 iPhones
  • Next by Date: Re: Initialising NSMutableArray
  • Previous by thread: Re: [iPhone] Network connection between 2 iPhones
  • Next by thread: Re: [iPhone] Network connection between 2 iPhones
  • Index(es):
    • Date
    • Thread