Saturday 25 April 2009

CFSocketCreate on iPhone

If you're doing sockets programming on your iPhone (like I'm doing for Mixtikl's file sharing server code), don't panic when your call to CFSocketCreate fails to create an IPv6 TCP socket when passing PF_INET6.

Just accept the IPv4 socket that you will get when passing-in PF_INET, and all will be fine... :)

2 comments:

Unknown said...

IS it failing because the server you're connecting to does not yet support IPv6?

Pete Cole said...

Hi Jim,

What I'm doing is creating a TCP sockets, which I use to run a local webserver (so other computers/mobiles on the local network can grab copies of files on that iPhone).

The iPhone supports creation of such sockets as IPv4, but not as IPv6. Which is fair enough. :) I guess that at some point it will support both types of socket...

Pete