Connect to Server from Iphone
OK, so I am new to Iphone programming. My basic aim is to understand the underlying design principles of multiplayer networking. So to start of, I guess I first need to connect different devices, kind of like a "hello world" using sockets to send and receive messages. Since I'm new to objective C, I decided to go for BSD sockets, and I have some experience there. So I can create a server that listens to incoming messages. Now how do I create an Iphone client that sends information to this server. Can I create a client sending socket from Iphone. How do I do that using BSD? Can I write a normal C code or do I have to have objective C style classes. I also see people using the term "wrapper" or "wrap around using Objective C", which is confusing. Help me.
BSD sockets are fully supported on the iPhone. The iPhone is really no different than a Mac in how you code for it.
General networking info:
http://developer.apple.com/iphone/librar...-CH21-SW26
Some specific peer-to-peer networking info:
http://developer.apple.com/iphone/librar...cepts.html
How to use BSD sockets:
http://beej.us/guide/bgnet/
An Objective-C "wrapper" around BSD sockets would simply be reusable Objective-C classes that implement sockets using the BSD socket layer. SmallSockets is an example of one.
General networking info:
http://developer.apple.com/iphone/librar...-CH21-SW26
Some specific peer-to-peer networking info:
http://developer.apple.com/iphone/librar...cepts.html
How to use BSD sockets:
http://beej.us/guide/bgnet/
An Objective-C "wrapper" around BSD sockets would simply be reusable Objective-C classes that implement sockets using the BSD socket layer. SmallSockets is an example of one.
Thanks for the reply.
Believe me, I'm trying hard to read in to your response. Please bear with my ignorance.
Now,
"The networking stack in iPhone OS includes several interfaces over the radio hardware of iPhone and iPod touch devices. The main programming interface is the CFNetwork frameworkFramework-p3d14-A framework is a bundle (a structured directory) that contains a dynamic shared library along with associated resources, such as nib files, image files, and header files. , which builds on top of BSD sockets and opaque types in the Core Foundation framework to communicate with network entities. You can also use the NSStream classes in the Foundation framework and the low-level BSD sockets found in the Core OS layer of the system."
The text above seems to give more handy info about CF framework but not about low level sockets found in Core OS. What is the difference between the two? Do I take it that a guy who is new to objective C would rather use the low-level BSD sockets found in the Core OS layer? If so, can I just about embed a client program that binds and send information using a low level socket from an objective C code? How do I use C-type functions in an objective C program? It's confusing.
Some specific peer-to-peer networking info:
This information uses bluetooth to communicate, which I can't use, since I'm connecting to a server out of range of bluetooth.
Believe me, I'm trying hard to read in to your response. Please bear with my ignorance.
Now,
"The networking stack in iPhone OS includes several interfaces over the radio hardware of iPhone and iPod touch devices. The main programming interface is the CFNetwork frameworkFramework-p3d14-A framework is a bundle (a structured directory) that contains a dynamic shared library along with associated resources, such as nib files, image files, and header files. , which builds on top of BSD sockets and opaque types in the Core Foundation framework to communicate with network entities. You can also use the NSStream classes in the Foundation framework and the low-level BSD sockets found in the Core OS layer of the system."
The text above seems to give more handy info about CF framework but not about low level sockets found in Core OS. What is the difference between the two? Do I take it that a guy who is new to objective C would rather use the low-level BSD sockets found in the Core OS layer? If so, can I just about embed a client program that binds and send information using a low level socket from an objective C code? How do I use C-type functions in an objective C program? It's confusing.
Some specific peer-to-peer networking info:
This information uses bluetooth to communicate, which I can't use, since I'm connecting to a server out of range of bluetooth.
BugSniper Wrote:How do I use C-type functions in an objective C program? It's confusing.
You use them exactly as you would in pure C code; #inlcude the appropriate header(s) and call the functions. There's nothing different about doing it in Objective-C. Remember, Objective-C is a direct superset of C.
BugSniper Wrote:The text above seems to give more handy info about CF framework but not about low level sockets found in Core OS. What is the difference between the two?
The former simply builds on the latter.
Quote:Do I take it that a guy who is new to objective C would rather use the low-level BSD sockets found in the Core OS layer?
If this guy is already familiar with BSD sockets, sure.
Quote:If so, can I just about embed a client program that binds and send information using a low level socket from an objective C code?
Yes.
Quote:This information uses bluetooth to communicate, which I can't use, since I'm connecting to a server out of range of bluetooth.
I included it for completeness. You didn't really specify your requirements.
I use Enet for my networking needs, its awesome IMHO
thank you guys.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| CrystalEngine server solution for any game project | Aldex | 0 | 2,953 |
Sep 1, 2011 01:45 AM Last Post: Aldex |
|
| P2P or Client/Server? | TokyoDan | 2 | 4,241 |
Aug 3, 2009 06:15 AM Last Post: georgiph |
|
| Server architecture advice needed :) | wyrmmage | 2 | 4,271 |
Jan 25, 2007 10:57 AM Last Post: wyrmmage |
|
| Server/database interaction in C++ using sockets | wyrmmage | 2 | 4,754 |
Jan 20, 2007 02:17 PM Last Post: wyrmmage |
|
| The need for connect/listen on raw sockets? | BinarySpike | 28 | 14,028 |
Oct 26, 2006 07:23 PM Last Post: akb825 |
|

