 |
 |
Cocoa and TCP?
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Charlotte, NC
Status:
Offline
|
|
Does the Foundation or AppKit include classes for TCP/IP communication, or would this be something someone would be interested in? If it doesn't include them, I'll probably end up writing a framework that implements it.
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2000
Status:
Offline
|
|
|
(Last edited by AirSluf; Nov 8, 2004 at 11:49 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
There is something in CoreFoundation called CFSocket, but there is very little documentation on it and it conforms to the methaphors of CF not of Obj-C/Cocoa. There is an Obj-C wrapper for BSD sockets called SmallSockets and is available at http://smallsockets.sourceforge.net/
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status:
Offline
|
|
There isn't too much in the way of (public) networking classes in Cocoa unfortunately. NSURL can retrieve the contents for file:// or http[s]:// URLs, and NSFileHandle can be initialized with a TCP socket's file descriptor, meaning you can use NSFileHandle methods to read/write/be notified etc. The Message framework has one header which provides an easy API for sending email (i.e. SMTP). Past that there's not much in the kits.
If you're writing Java/Cocoa you obviously have all the Java networking APIs available. Even if you're primarily in Objective-C, there's nothing stopping you from writing one particular piece in Java so you can use Java networking, and messaging that one piece from ObjC across the bridge.
There are several third-party packages out there, as mentioned. The Omni frameworks are involved but offer a lot of stuff, whereas smallsockets (probably; I've never used it) gives you a lightweight API to TCP sockets.
EDInternet is probably somewhere in the middle, offering a handful of classes for different socket types that can be used as a basis for implementing higher level protocols (I think the author used them as part of an NNTP implementation). There is also
CURLHandle, which (according to its documentation) is a wrapper around libcurl in the form of an NSURLHandle subclass that can handle lots more types of URLs and provides for things like fetching in a background thread.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
There's a implementation out there called SmallSockets - it's a Obj-C implementation of sockets.
Keep in mind that you can also just use C code to call the BSD sockets API.
Wade
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Brisbane, Queensland, Australia
Status:
Offline
|
|
Personally I find using the C code just as easy for simple things. But there is absolutely no documentation on CFSocket I can find anywhere! No examples either!
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Aug 2001
Location: Vienna, Austria
Status:
Offline
|
|
Originally posted by sordid:
<STRONG>Personally I find using the C code just as easy for simple things. But there is absolutely no documentation on CFSocket I can find anywhere! No examples either!</STRONG>
Read the header file CFSocket.h, it's pretty well documented. CFSocket is just a CF-wrapper around BSD sockets.
I usually just create a regular socket and use CFSocketCreateWithNative to convert it into a CFSocket for inserting into the current CFRunLoop (for getting a callback when new data arrives).
I've written an article that covers it roughly (including a CFSocket example!) which is available at cocoadevcentral.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Brisbane, Queensland, Australia
Status:
Offline
|
|
Originally posted by amonitzer:
<STRONG>
Read the header file CFSocket.h, it's pretty well documented. CFSocket is just a CF-wrapper around BSD sockets.
I usually just create a regular socket and use CFSocketCreateWithNative to convert it into a CFSocket for inserting into the current CFRunLoop (for getting a callback when new data arrives).
I've written an article that covers it roughly (including a CFSocket example!) which is available at cocoadevcentral.</STRONG>
Thanks for the tips.. they have been very helpful.

|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|