Re: [iPhone] networking

2009-08-06 Thread James Lin
How does Bonjour handle the task of introducing 2 iPhones (located in  
2 parts of the world) to each other?


The documentations i've found so far all point to Bonjour working on  
local network only, (even on Apple's website).
Can you please point me to the documentation where it explains how  
Bonjour works over the internet?


My goal:

1. 1 iPhone running my app working as a server waiting for connection  
from another iPhone from the internet.
2. Another iPhone running my app working as a client connects to the  
server iPhone and send a string hi, I am James.
3. The server iPhone, upon receiving this string reply with user's  
choice of either String A or String B back to the client iPhone.


From the comment below...if an iPhone is never going to have a public  
IP address...

How do I make 1 iPhone connect to another?


Sorry for the repeating question...I am just getting more and more  
confused instead so far...


Thank you in advance...

James

On 2009/8/5, at 上午 2:13, Luke the Hiesterman wrote:



On Aug 4, 2009, at 11:10 AM, James Lin wrote:


Bonjour is for local area network, right?


No, Bonjour is applicable to any networking, local or wide area.  
Here's some sample code.


http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html

Luke



On 2009/8/6, at 上午 7:58, glenn andreas wrote:



On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote:

On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiestermanluket...@apple.com 
 wrote:


On Aug 4, 2009, at 11:10 AM, James Lin wrote:


Bonjour is for local area network, right?


No, Bonjour is applicable to any networking, local or wide area.  
Here's some

sample code.

http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html


Well ad-hoc discovery only works on the local sub-net or across
bridged sub-nets. To do service discovery across sub-nets would
require a known DNS server publishing the existence of services and
how to contact them via public IP addresses.



Of course, in the context of the original question (re: iPhone  
networking), the iPhone is almost never going to have a public IP  
address (being hidden behind WiFi or cell phone NATs).



Glenn Andreas  gandr...@gandreas.com
http://www.gandreas.com/ wicked fun!
Mad, Bad, and Dangerous to Know

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread James Lin



My goal:
1. 1 iPhone running my app working as a server waiting for  
connection  from another iPhone from the internet.
2. Another iPhone running my app working as a client connects to  
the  server iPhone and send a string hi, I am James.
3. The server iPhone, upon receiving this string reply with user's   
choice of either String A or String B back to the client iPhone.
From the comment below...if an iPhone is never going to have a  
public  IP address...

How do I make 1 iPhone connect to another?


You basically can't, and people have been trying to tell you this  
for some time now, most of the replies to your questions have said  
exactly that, you can't network through NAT, phones don't have  
public IP addresses, or they rarely do.




So, if I cannot make 2 iPhones talk to each other, but I have a php/ 
mysql server.


Can my other option be the following?

1. iPhone A post the message Hi, I am James to the php/mysql server  
and specifies the message is for iPhone B.
2. iPhone B running my app keeps querrying the php/mysql server for  
message left for it with a querry to php/mysql server inside a   
NSTimer (say querry once every 30 seconds).
3. iPhone B, upon getting a result that there is a message from iPhone  
B, do whatever it needs to do and post the reply back to the php/mysql  
server.
4. iPhone A, inside a NSTimer, querrys the php/mysql server for result  
of the original posting from B.


Is this my best option given what I want to accomplish?

Thanks in advance...


James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread Keith Duncan


On 6 Aug 2009, at 09:13, Roland King wrote:

I've never seen any. I assume that as well as multicast dns there  
are ways to configure bonjour to point to some central DNS server  
which would enable something like that to work


Yes, you can use regular unicast DNS, and query a specified DNS server  
for SRV records.


Keith
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread Keith Duncan


On 6 Aug 2009, at 09:27, James Lin wrote:


[...]

keeps querrying the php/mysql server for message left for it with a  
querry to php/mysql server inside a  NSTimer (say querry once every  
30 seconds).


[...]

Is this my best option given what I want to accomplish?



I'm afraid it isn't, polling a server is a pretty bad idea, on the  
iPhone in particular; it will drain the battery quickly. It sounds  
like you need some kind of messaging server, to which the clients  
maintain a persistent connection.


Keith
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread James Lin

Can you please elaborate a bit more?

What technology option do I have when it comes to a messaging server?
What's involved on the iPhone's side?

Thank you in advance...

James

On 2009/8/6, at 下午 4:33, Keith Duncan wrote:



On 6 Aug 2009, at 09:27, James Lin wrote:


[...]

keeps querrying the php/mysql server for message left for it with a  
querry to php/mysql server inside a  NSTimer (say querry once every  
30 seconds).


[...]

Is this my best option given what I want to accomplish?



I'm afraid it isn't, polling a server is a pretty bad idea, on the  
iPhone in particular; it will drain the battery quickly. It sounds  
like you need some kind of messaging server, to which the clients  
maintain a persistent connection.


Keith


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread Jeremy Pereira


On 6 Aug 2009, at 09:27, James Lin wrote:



Is this my best option given what I want to accomplish?

Thanks in advance...


Stepping back a little bit.  Are you trying to build some sort of real  
time messaging service?  Or does it matter if the second phone doesn't  
receive the message straight away?


Have you considered sending an SMS message from one phone to the other?

Actually scratch that, there's no official iPhone SMS API according to  
Google.


Or what about setting up a mail server?  iPhone 1 sends the message  
using SMTP and iPhone 2 retrieves it using IMAP.





James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-06 Thread James Lin
well...I guess you can call it some sort of real time messaging  
service...


I just need to send a string from iPhoneA to iPhoneB.
And allow iPhoneB to reply with another string back to iPhoneA.

That's all I am trying to do.
I had no idea it is so difficult and involves so much.

given my state of confusion right now, any suggestion you can give me  
is much appreciated...


Thanx in advance...

James
On 2009/8/6, at 下午 10:18, Jeremy Pereira wrote:



On 6 Aug 2009, at 09:27, James Lin wrote:



Is this my best option given what I want to accomplish?

Thanks in advance...


Stepping back a little bit.  Are you trying to build some sort of  
real time messaging service?  Or does it matter if the second phone  
doesn't receive the message straight away?


Have you considered sending an SMS message from one phone to the  
other?


Actually scratch that, there's no official iPhone SMS API according  
to Google.


Or what about setting up a mail server?  iPhone 1 sends the message  
using SMTP and iPhone 2 retrieves it using IMAP.





James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/adc%40jeremyp.net

This email sent to a...@jeremyp.net




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-05 Thread glenn andreas


On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote:

On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiestermanluket...@apple.com 
 wrote:


On Aug 4, 2009, at 11:10 AM, James Lin wrote:


Bonjour is for local area network, right?


No, Bonjour is applicable to any networking, local or wide area.  
Here's some

sample code.

http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html


Well ad-hoc discovery only works on the local sub-net or across
bridged sub-nets. To do service discovery across sub-nets would
require a known DNS server publishing the existence of services and
how to contact them via public IP addresses.



Of course, in the context of the original question (re: iPhone  
networking), the iPhone is almost never going to have a public IP  
address (being hidden behind WiFi or cell phone NATs).



Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
Mad, Bad, and Dangerous to Know

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-05 Thread Kyle Sluder

On Aug 4, 2009, at 4:42 PM, Shawn Erickson wrote:


Of course, in the context of the original question (re: iPhone  
networking), the iPhone is almost never going to have a public IP  
address (being hidden behind WiFi or cell phone NATs).


Assuming cell carriers don't get off their butts and implement IPv6.  
There's no guarantee of that, especially if China gets the iPhone.


--Kyle Sluder



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-05 Thread Kaelten
Just brainstorming theory here, but it might be made much easier if
you had a server act as an intermediary, even if all that server does
is 'introduce' the two iphones to each other.

Bryan McLemore
Kaelten



On Tue, Aug 4, 2009 at 1:10 PM, James Linjamesclin...@gmail.com wrote:
 Correct me if I am wrong...but from what i have read so far...

 Bonjour is for local area network, right?

 What I am trying to do is to get 2 iPhones located in 2 different part of
 the world to connect to each other on the internet.
 Can Bonjour work?

 Thanx in advance...

 James
 On 2009/8/5, at 上午 2:02, glenn andreas wrote:


 On Aug 4, 2009, at 12:49 PM, James Lin wrote:

 I am trying to make the iPhone a server and a client at the same time...

 What I am trying to accomplish...

 1. iPhone running my application opens a server socket and listens for
 incoming network connection from another iPhone running the same
 application.
 2. The server socket has an ip address that i can register with my
 php/mysql server.
 3. Another iPhone running my same app acts as the client gets the iPhone
 server's ip address from the server and make connection to the server
 iPhone.
 4. The client iPhone sends a string hello, I am James to the server
 iPhone and the server iPhone reply with the user's choice of either Hi,
 Nice to meet you or Get lost! strings.


 Unless the two phones are on the same local WiFi network, due to the way
 that various NATs (especially with cell phone networking), a client will
 almost certainly not be able  to connect to a server running on the phone.
  Basically, the phone see only a local (private) network, and will have an
 address such as 10.3.5.12.  Unfortunately, that IP address is meaningless
 outside of local network (there is no way for a  remote phone, which may
 have the exact same address, to find 10.3.5.12 as being your local phone).

 Given that trying to support phone based servers isn't going to work
 except for within the same WiFi network, you might as well instead use
 Bonjour for one  phone to discover the other phone (which will automatically
 handle finding/resolving/advertising ip address/ports).


 Glenn Andreas                      gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
 Mad, Bad, and Dangerous to Know


 ___

 Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

 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:
 http://lists.apple.com/mailman/options/cocoa-dev/kaelten%40gmail.com

 This email sent to kael...@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


[iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread James Lin

Hi all,

Does anyone know the limitation of the iPhone simulator when it comes  
to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained from  
google codes.


but i've so far failed to obtain the ip address of the server socket.

the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's limiting  
the networking functionality on the simulator.


Does anyone know?

Thank you...

James
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread John C. Randolph


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained from  
google codes.


but i've so far failed to obtain the ip address of the server  
socket.


the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's  
limiting the networking functionality on the simulator.


Does anyone know?


Safari works for me on the simulator, so it's got to have  
communications.  Does the same code work if you load it on your phone?


-jcr
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread James Lin

Safari works for me too...
The reason I am asking this seemingly redundant question is simply :
I don't have an iPhone yet (3GS won't be available in my country until  
end of Aug)

and I am doing all my programming blind on the simulator.

if networking is crippled on the simulator, that means my development  
work has to take a break until

I get my hands on an actual iPhone..

Does anyone know?

Thank you in advance...

James


On 2009/8/4, at 下午 9:04, John C. Randolph wrote:



On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained from  
google codes.


but i've so far failed to obtain the ip address of the server  
socket.


the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's  
limiting the networking functionality on the simulator.


Does anyone know?


Safari works for me on the simulator, so it's got to have  
communications.  Does the same code work if you load it on your phone?


-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread Roland King

it is not crippled

On Aug 4, 2009, at 9:48 PM, James Lin wrote:


Safari works for me too...
The reason I am asking this seemingly redundant question is simply :
I don't have an iPhone yet (3GS won't be available in my country  
until end of Aug)

and I am doing all my programming blind on the simulator.

if networking is crippled on the simulator, that means my  
development work has to take a break until

I get my hands on an actual iPhone..

Does anyone know?

Thank you in advance...

James


On 2009/8/4, at 下午 9:04, John C. Randolph wrote:



On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained  
from google codes.


but i've so far failed to obtain the ip address of the server  
socket.


the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's  
limiting the networking functionality on the simulator.


Does anyone know?


Safari works for me on the simulator, so it's got to have  
communications.  Does the same code work if you load it on your  
phone?


-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/rols%40rols.org

This email sent to r...@rols.org


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread Luke the Hiesterman
Networking should work on the simulator. There are several networking  
related pieces of sample code that work on the simulator.


http://developer.apple.com/iphone/library/navigation/SampleCode.html

Luke

On Aug 4, 2009, at 6:48 AM, James Lin wrote:


Safari works for me too...
The reason I am asking this seemingly redundant question is simply :
I don't have an iPhone yet (3GS won't be available in my country  
until end of Aug)

and I am doing all my programming blind on the simulator.

if networking is crippled on the simulator, that means my  
development work has to take a break until

I get my hands on an actual iPhone..

Does anyone know?

Thank you in advance...

James


On 2009/8/4, at 下午 9:04, John C. Randolph wrote:



On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.
1. is by opening up a CFSocket
2. is by a socket wrapper class called LXSocket class obtained  
from google codes.


but i've so far failed to obtain the ip address of the server  
socket.


the CFSocket method returned the ip address as 0.0.0.0
the LXSocket class returned the ip address as a Null object.

I am wondering, if there is a limitation of some kind that's  
limiting the networking functionality on the simulator.


Does anyone know?


Safari works for me on the simulator, so it's got to have  
communications.  Does the same code work if you load it on your  
phone?


-jcr


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com

This email sent to luket...@apple.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking-is it crippled on the simulator?

2009-08-04 Thread Dave Camp

On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a server  
somewhere, or that you are trying to open a low numbered (i.e.  1024)  
port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound connections  
but iPhones running OS 3.0 and later can.


Dave
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread James Lin

I am trying to make the iPhone a server and a client at the same time...

What I am trying to accomplish...

1. iPhone running my application opens a server socket and listens  
for incoming network connection from another iPhone running the same  
application.
2. The server socket has an ip address that i can register with my  
php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to the  
server iPhone.
4. The client iPhone sends a string hello, I am James to the server  
iPhone and the server iPhone reply with the user's choice of either  
Hi, Nice to meet you or Get lost! strings.


ps. the port number i chose was 2048

This is all i am trying to accomplish, but i am making slow progress  
and banging my head against the wall...

Any ideas/suggestions are greatly appreciated...

Thanx again...

James


On 2009/8/4, at 下午 11:50, Dave Camp wrote:


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a  
server somewhere, or that you are trying to open a low numbered  
(i.e.  1024) port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound connections  
but iPhones running OS 3.0 and later can.


Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread Luke the Hiesterman

Have you tried using CFHost to get your IP?

Luke

On Aug 4, 2009, at 10:49 AM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and listens  
for incoming network connection from another iPhone running the same  
application.
2. The server socket has an ip address that i can register with my  
php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice of  
either Hi, Nice to meet you or Get lost! strings.


ps. the port number i chose was 2048

This is all i am trying to accomplish, but i am making slow progress  
and banging my head against the wall...

Any ideas/suggestions are greatly appreciated...

Thanx again...

James


On 2009/8/4, at 下午 11:50, Dave Camp wrote:


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a  
server somewhere, or that you are trying to open a low numbered  
(i.e.  1024) port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound  
connections but iPhones running OS 3.0 and later can.


Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com

This email sent to luket...@apple.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread glenn andreas


On Aug 4, 2009, at 12:49 PM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and listens  
for incoming network connection from another iPhone running the same  
application.
2. The server socket has an ip address that i can register with my  
php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice of  
either Hi, Nice to meet you or Get lost! strings.



Unless the two phones are on the same local WiFi network, due to the  
way that various NATs (especially with cell phone networking), a  
client will almost certainly not be able  to connect to a server  
running on the phone.  Basically, the phone see only a local (private)  
network, and will have an address such as 10.3.5.12.  Unfortunately,  
that IP address is meaningless outside of local network (there is no  
way for a  remote phone, which may have the exact same address, to  
find 10.3.5.12 as being your local phone).


Given that trying to support phone based servers isn't going to work  
except for within the same WiFi network, you might as well instead use  
Bonjour for one  phone to discover the other phone (which will  
automatically handle finding/resolving/advertising ip address/ports).



Glenn Andreas  gandr...@gandreas.com
 http://www.gandreas.com/ wicked fun!
Mad, Bad, and Dangerous to Know

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread James Lin

I am not using CFHost...

I use the CFSocketCopyAddress() on a CFSocketRef (my server socket)  
called TCPServer.


CFDataRef serverAddressData = CFSocketCopyAddress(TCPServer);
NSString *serverAddressString;
serverAddressString = [NSString stringWithFormat: @%@, [self  
addressHost:serverAddressData]];

NSLog(@Server started at %@, serverAddressString);

and the addressHost function to return the ip address as follows:

- (NSString *) addressHost: (CFDataRef)cfaddr
{
if (cfaddr == NULL) return nil;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
	struct sockaddr *pSockAddr = (struct sockaddr *) CFDataGetBytePtr  
(cfaddr);

struct sockaddr_in  *pSockAddrV4 = (struct sockaddr_in *) pSockAddr;
struct sockaddr_in6 *pSockAddrV6 = (struct sockaddr_in6 *)pSockAddr;

const void *pAddr = (pSockAddr-sa_family == AF_INET) ?
(void *)((pSockAddrV4-sin_addr)) :
(void *)((pSockAddrV6-sin6_addr));

	const char *pStr = inet_ntop (pSockAddr-sa_family, pAddr, addrBuf,  
sizeof(addrBuf));

if (pStr == NULL) [NSException raise: NSInternalInconsistencyException
  format: @Cannot 
convert address to string.];

	return [NSString stringWithCString:pStr  
encoding:NSASCIIStringEncoding];

}

The NSLog result is : Server started at 0.0.0.0

Any ideas?

Thanx in advance...

James

On 2009/8/5, at 上午 1:52, Luke the Hiesterman wrote:


Have you tried using CFHost to get your IP?

Luke

On Aug 4, 2009, at 10:49 AM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and  
listens for incoming network connection from another iPhone running  
the same application.
2. The server socket has an ip address that i can register with  
my php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice of  
either Hi, Nice to meet you or Get lost! strings.


ps. the port number i chose was 2048

This is all i am trying to accomplish, but i am making slow  
progress and banging my head against the wall...

Any ideas/suggestions are greatly appreciated...

Thanx again...

James


On 2009/8/4, at 下午 11:50, Dave Camp wrote:


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a  
server somewhere, or that you are trying to open a low numbered  
(i.e.  1024) port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound  
connections but iPhones running OS 3.0 and later can.


Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com

This email sent to luket...@apple.com




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread Luke the Hiesterman
It looks like you're asking for the IP address from a socket before  
you've given it an IP. As someone said earlier, you have to bind an IP  
address to a socket - it doesn't just come out of thin air.


Luke

On Aug 4, 2009, at 11:07 AM, James Lin wrote:


I am not using CFHost...

I use the CFSocketCopyAddress() on a CFSocketRef (my server socket)  
called TCPServer.


CFDataRef serverAddressData = CFSocketCopyAddress(TCPServer);
NSString *serverAddressString;
serverAddressString = [NSString stringWithFormat: @%@, [self  
addressHost:serverAddressData]];

NSLog(@Server started at %@, serverAddressString);

and the addressHost function to return the ip address as follows:

- (NSString *) addressHost: (CFDataRef)cfaddr
{
if (cfaddr == NULL) return nil;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
	struct sockaddr *pSockAddr = (struct sockaddr *) CFDataGetBytePtr  
(cfaddr);

struct sockaddr_in  *pSockAddrV4 = (struct sockaddr_in *) pSockAddr;
struct sockaddr_in6 *pSockAddrV6 = (struct sockaddr_in6 *)pSockAddr;

const void *pAddr = (pSockAddr-sa_family == AF_INET) ?
(void *)((pSockAddrV4-sin_addr)) :
(void *)((pSockAddrV6-sin6_addr));

	const char *pStr = inet_ntop (pSockAddr-sa_family, pAddr, addrBuf,  
sizeof(addrBuf));
	if (pStr == NULL) [NSException raise:  
NSInternalInconsistencyException

  format: @Cannot 
convert address to string.];

	return [NSString stringWithCString:pStr  
encoding:NSASCIIStringEncoding];

}

The NSLog result is : Server started at 0.0.0.0

Any ideas?

Thanx in advance...

James

On 2009/8/5, at 上午 1:52, Luke the Hiesterman wrote:


Have you tried using CFHost to get your IP?

Luke

On Aug 4, 2009, at 10:49 AM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and  
listens for incoming network connection from another iPhone  
running the same application.
2. The server socket has an ip address that i can register with  
my php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice  
of either Hi, Nice to meet you or Get lost! strings.


ps. the port number i chose was 2048

This is all i am trying to accomplish, but i am making slow  
progress and banging my head against the wall...

Any ideas/suggestions are greatly appreciated...

Thanx again...

James


On 2009/8/4, at 下午 11:50, Dave Camp wrote:


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a  
server somewhere, or that you are trying to open a low numbered  
(i.e.  1024) port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound  
connections but iPhones running OS 3.0 and later can.


Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh 
%40apple.com


This email sent to luket...@apple.com






___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread James Lin

Correct me if I am wrong...but from what i have read so far...

Bonjour is for local area network, right?

What I am trying to do is to get 2 iPhones located in 2 different part  
of the world to connect to each other on the internet.

Can Bonjour work?

Thanx in advance...

James
On 2009/8/5, at 上午 2:02, glenn andreas wrote:



On Aug 4, 2009, at 12:49 PM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and  
listens for incoming network connection from another iPhone running  
the same application.
2. The server socket has an ip address that i can register with  
my php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice of  
either Hi, Nice to meet you or Get lost! strings.



Unless the two phones are on the same local WiFi network, due to the  
way that various NATs (especially with cell phone networking), a  
client will almost certainly not be able  to connect to a server  
running on the phone.  Basically, the phone see only a local  
(private) network, and will have an address such as 10.3.5.12.   
Unfortunately, that IP address is meaningless outside of local  
network (there is no way for a  remote phone, which may have the  
exact same address, to find 10.3.5.12 as being your local phone).


Given that trying to support phone based servers isn't going to work  
except for within the same WiFi network, you might as well instead  
use Bonjour for one  phone to discover the other phone (which will  
automatically handle finding/resolving/advertising ip address/ports).



Glenn Andreas  gandr...@gandreas.com
http://www.gandreas.com/ wicked fun!
Mad, Bad, and Dangerous to Know



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread James Lin
I did call CFSocketSetAddress in my socket setup code to bind an IP  
address to a socket before the above code asking for ip...


Thanx in advance...

James
On 2009/8/5, at 上午 2:09, Luke the Hiesterman wrote:

It looks like you're asking for the IP address from a socket before  
you've given it an IP. As someone said earlier, you have to bind an  
IP address to a socket - it doesn't just come out of thin air.


Luke

On Aug 4, 2009, at 11:07 AM, James Lin wrote:


I am not using CFHost...

I use the CFSocketCopyAddress() on a CFSocketRef (my server socket)  
called TCPServer.


CFDataRef serverAddressData = CFSocketCopyAddress(TCPServer);
NSString *serverAddressString;
serverAddressString = [NSString stringWithFormat: @%@, [self  
addressHost:serverAddressData]];

NSLog(@Server started at %@, serverAddressString);

and the addressHost function to return the ip address as follows:

- (NSString *) addressHost: (CFDataRef)cfaddr
{
if (cfaddr == NULL) return nil;
char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
	struct sockaddr *pSockAddr = (struct sockaddr *) CFDataGetBytePtr  
(cfaddr);

struct sockaddr_in  *pSockAddrV4 = (struct sockaddr_in *) pSockAddr;
struct sockaddr_in6 *pSockAddrV6 = (struct sockaddr_in6 *)pSockAddr;

const void *pAddr = (pSockAddr-sa_family == AF_INET) ?
(void *)((pSockAddrV4-sin_addr)) :
(void *)((pSockAddrV6-sin6_addr));

	const char *pStr = inet_ntop (pSockAddr-sa_family, pAddr,  
addrBuf, sizeof(addrBuf));
	if (pStr == NULL) [NSException raise:  
NSInternalInconsistencyException

  format: @Cannot 
convert address to string.];

	return [NSString stringWithCString:pStr  
encoding:NSASCIIStringEncoding];

}

The NSLog result is : Server started at 0.0.0.0

Any ideas?

Thanx in advance...

James

On 2009/8/5, at 上午 1:52, Luke the Hiesterman wrote:


Have you tried using CFHost to get your IP?

Luke

On Aug 4, 2009, at 10:49 AM, James Lin wrote:

I am trying to make the iPhone a server and a client at the same  
time...


What I am trying to accomplish...

1. iPhone running my application opens a server socket and  
listens for incoming network connection from another iPhone  
running the same application.
2. The server socket has an ip address that i can register with  
my php/mysql server.
3. Another iPhone running my same app acts as the client gets the  
iPhone server's ip address from the server and make connection to  
the server iPhone.
4. The client iPhone sends a string hello, I am James to the  
server iPhone and the server iPhone reply with the user's choice  
of either Hi, Nice to meet you or Get lost! strings.


ps. the port number i chose was 2048

This is all i am trying to accomplish, but i am making slow  
progress and banging my head against the wall...

Any ideas/suggestions are greatly appreciated...

Thanx again...

James


On 2009/8/4, at 下午 11:50, Dave Camp wrote:


On Aug 4, 2009, at 5:43 AM, James Lin wrote:


Hi all,

Does anyone know the limitation of the iPhone simulator when it  
comes to networking?

Is it crippled on the simulator?

I've tried two seperate ways of opening up a server socket.


By server socket, do you mean you are trying to connect to a  
server somewhere, or that you are trying to open a low numbered  
(i.e.  1024) port locally so that you can be a server?


The simulator cannot open low numbered ports for inbound  
connections but iPhones running OS 3.0 and later can.


Dave


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/luketheh%40apple.com

This email sent to luket...@apple.com








___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] networking

2009-08-04 Thread Shawn Erickson
On Tue, Aug 4, 2009 at 11:13 AM, Luke the Hiestermanluket...@apple.com wrote:

 On Aug 4, 2009, at 11:10 AM, James Lin wrote:

 Bonjour is for local area network, right?

 No, Bonjour is applicable to any networking, local or wide area. Here's some
 sample code.

 http://developer.apple.com/iphone/library/samplecode/BonjourWeb/index.html

Well ad-hoc discovery only works on the local sub-net or across
bridged sub-nets. To do service discovery across sub-nets would
require a known DNS server publishing the existence of services and
how to contact them via public IP addresses.

-Shawn
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com