Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 25, 2012, 10:32 AM   #1
dancks
macrumors member
 
Join Date: Nov 2009
Mac API for networking?

I'm learning about networking, and I would like to apply what I'm learning by making a chat-type application and send packets on the network. (one side would be an AI type thing). For ports I would probably use the high port numbers reserved for random conversation assignment. I'm curious how I would go about doing this. I asked my teacher awhile back he said there are networking specific headers in C and there are usually a port or some freeware to communicate with lower level data link or networking layer. Is this possible? I'm a little lost on where to get started.
dancks is offline   0 Reply With Quote
Old Feb 25, 2012, 11:06 AM   #2
KnightWRX
macrumors Pentium
 
KnightWRX's Avatar
 
Join Date: Jan 2009
Location: Quebec, Canada
You can go very low-level and just use the BSD socket API.

This page should cover it :

http://www.cs.vu.nl/~jms/socket-info.html

Apple has higher level stuff if you don't want to learn the "RAW" way :

https://developer.apple.com/library/.../Concepts.html
__________________
"What you leave behind is not what is engraved in stone monuments, but what is woven into the lives of others."
-- Pericles
KnightWRX is offline   0 Reply With Quote
Old Feb 25, 2012, 11:54 AM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
What language do you intend to program this in?

There are shell commands you can use to send and receive network packets at a fairly high level. The 'nc' command (a.k.a. netcat) can both send and receive, using TCP or UDP. The 'curl' command can use the HTTP, FTP, and other protocols.

Other languages, such as perl, python, C, C++, Objective-C, Java, JavaScript, etc. have their own networking functions and classes.
chown33 is offline   0 Reply With Quote
Old Feb 25, 2012, 12:05 PM   #4
KnightWRX
macrumors Pentium
 
KnightWRX's Avatar
 
Join Date: Jan 2009
Location: Quebec, Canada
Quote:
Originally Posted by chown33 View Post
What language do you intend to program this in?

There are shell commands you can use to send and receive network packets at a fairly high level. The 'nc' command (a.k.a. netcat) can both send and receive, using TCP or UDP. The 'curl' command can use the HTTP, FTP, and other protocols.

Other languages, such as perl, python, C, C++, Objective-C, Java, JavaScript, etc. have their own networking functions and classes.
I assume the OP means in C :

Quote:
Originally Posted by dancks View Post
I asked my teacher awhile back he said there are networking specific headers in C
(Nitpick : his teacher is actually wrong, there are no networking specific headers in C. C doesn't know about networking. Ultimately, networking is a platform specific endeavour. In OS X, it's either BSD sockets or higher level Apple frameworks for C work).
__________________
"What you leave behind is not what is engraved in stone monuments, but what is woven into the lives of others."
-- Pericles
KnightWRX is offline   0 Reply With Quote
Old Feb 25, 2012, 12:09 PM   #5
subsonix
macrumors 68030
 
Join Date: Feb 2008
Look for a socket api for what ever language or framework you intent to use, it's available for most of them.
subsonix is offline   0 Reply With Quote
Old Feb 25, 2012, 06:49 PM   #6
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
Quote:
Originally Posted by dancks View Post
I'm learning about networking, and I would like to apply what I'm learning by making a chat-type application and send packets on the network. (one side would be an AI type thing). For ports I would probably use the high port numbers reserved for random conversation assignment. I'm curious how I would go about doing this. I asked my teacher awhile back he said there are networking specific headers in C and there are usually a port or some freeware to communicate with lower level data link or networking layer. Is this possible? I'm a little lost on where to get started.
Here you go!

http://beej.us/guide/bgnet/output/ht...age/index.html

If you want to make a chat program (to type in) and server (for the AI to be in) you are going to put the code in something like a CFRunloop
robvas is offline   0 Reply With Quote
Old Feb 26, 2012, 07:54 AM   #7
dancks
Thread Starter
macrumors member
 
Join Date: Nov 2009
Quote:
Originally Posted by KnightWRX View Post
You can go very low-level and just use the BSD socket API.

This page should cover it :

http://www.cs.vu.nl/~jms/socket-info.html

Apple has higher level stuff if you don't want to learn the "RAW" way :

https://developer.apple.com/library/.../Concepts.html
Thanks KnightWRX I'll definitely check out both but like you said I was interested in something C specific. I remember stumbling across a wiki page about a C header that had a packet header struct. It might have been part of a bigger library. If only I could remember what that was. Also robvas, I'll give a look.
dancks is offline   0 Reply With Quote
Old Feb 26, 2012, 08:20 AM   #8
KnightWRX
macrumors Pentium
 
KnightWRX's Avatar
 
Join Date: Jan 2009
Location: Quebec, Canada
Quote:
Originally Posted by dancks View Post
Thanks KnightWRX I'll definitely check out both but like you said I was interested in something C specific. I remember stumbling across a wiki page about a C header that had a packet header struct. It might have been part of a bigger library. If only I could remember what that was. Also robvas, I'll give a look.
Both of the links I gave you are C implementations. C itself has no networking sub system in the standard ANSI library.
__________________
"What you leave behind is not what is engraved in stone monuments, but what is woven into the lives of others."
-- Pericles
KnightWRX is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
API to find specs of a mac by serial number Bolzenheim OS X Mavericks (10.9) 5 Dec 10, 2013 03:38 PM
Amazon Expands In-App Purchase API to Mac, PC, and Web Apps MacRumors MacRumors.com News Discussion 17 Apr 9, 2013 06:53 AM
Need Help with Mac Networking. A.Christopher Mac OS X Server, Xserve, and Networking 5 Mar 5, 2013 06:07 AM
Skype Desktop API delegate methods doesn't get called on Mac OSX saqibjaan Mac Programming 0 Nov 16, 2012 12:31 AM
Tweetbot for Mac Alpha Program Ended Over Twitter API Restrictions MacRumors Mac Blog Discussion 44 Oct 4, 2012 09:19 AM

Forum Jump

All times are GMT -5. The time now is 03:56 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC