 |
 |
Cocoa Networking
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: England
Status:
Offline
|
|
I'm after info on cocoa networking. I'm a novice developer (to Cocoa, anyhow) and am trying to learn Cocoa programming by working on a project. This project is a client for a multi-user bell ringing simulator (spec here) that a friend is writing.
I'm after what framework to use to take care of the networking. I would ideally like something that I could set listening and then whenever it receives a packet it calls a delegate, or something along those lines. The problem is packets are variable length, so I can't ask it to read for a certain length at a time.
I've looked at Omni's networking framework but it seems to require multithreading. I've also looked at AGKit which looks ok, but has not been updated for a while.
Is there anything built into Cocoa that I could use? NSFileHandle seems to read to the end of the file each time, not to whatever the packet separator character is (it's probably a \n newline). I have no problem only targetting Tiger if there are some new APIs.
Thanks for your help.
Amorya
|
|
What the nerd community most often fail to realize is that all features aren't equal. A well implemented and well integrated feature in a convenient interface is worth way more than the same feature implemented crappy, or accessed through a annoying interface.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status:
Offline
|
|
You can use NSFileHandle and maintain the packet state yourself. In other words, you keep an accumulator into which you place any incoming data. Whenever you get new data, check the accumulator - if you've got a complete packet in there, pull it out, process it, and leave whatever is left to keep on accumulating.
The Chicken of the VNC source code illustrates this technique.
|
Geekspiff - generating spiffdiddlee software since before you began paying attention.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: England
Status:
Offline
|
|
Could I have it send a message to one of my objects when there was data to be read? I imagine it would use delegates... If I used the accumulator idea, I could have one object (WBLPacketProcessor or something) that split it into packets and then sent on the required message - but it'd need to be called at the appropriate time.
People around me are suggesting using a big loop. I'm at a LAN party surrounded by non-OO programmers
Amorya
|
|
What the nerd community most often fail to realize is that all features aren't equal. A well implemented and well integrated feature in a convenient interface is worth way more than the same feature implemented crappy, or accessed through a annoying interface.
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2001
Location: Wisconsin
Status:
Offline
|
|
I made a few simple additions to smallsockets awhile ago that does pretty much what you asked. I can send it to you someway if you want.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: England
Status:
Offline
|
|
Yes please! My email is:
amorya at amorya dot freeserve dot co dot uk
Replace at with @ and dot with .
Cheers
Amorya
|
|
What the nerd community most often fail to realize is that all features aren't equal. A well implemented and well integrated feature in a convenient interface is worth way more than the same feature implemented crappy, or accessed through a annoying interface.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 1999
Location: San Jose, Ca
Status:
Offline
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Originally Posted by larkost
Um... why are you not just using distributed objects?
Presumably because the server that the client is supposed to connect to doesn't use DO?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Mar 2001
Location: England
Status:
Offline
|
|
Originally Posted by Chuckit
Presumably because the server that the client is supposed to connect to doesn't use DO?
Yup
Server is (I think) written in plain C. There will eventually be many clients for different OSs.
Amorya
|
|
What the nerd community most often fail to realize is that all features aren't equal. A well implemented and well integrated feature in a convenient interface is worth way more than the same feature implemented crappy, or accessed through a annoying interface.
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|