Socket Library on OSX? - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Tools & Technology (/forum-10.html)
+--- Thread: Socket Library on OSX? (/thread-3657.html)
Pages: 1 2
Socket Library on OSX? - MacFiend - Dec 6, 2006 10:10 PM
I'm looking for a good, easy-to-use socket library for Carbon.
I found some good ones for Cocoa (NetSocket, AsyncSocket), but sadly, I've moved on from Cocoa to bigger and brighter things.
I know I could write my own using CFNetwork, but I figure that somebody must have done it already. I don't really want to concern myself with the low-level programming as of yet; I just want to play around with high-level networking with C++. So I'm looking for the quickest/easiest way out.
So, can anybody recommend a good socket library for Carbon? Preferably one that encompasses CFNetwork into a handy C++ class. I've read about BSD sockets, and I'm sure there are dozens of classes ready for use, but I'd still like to get a recommendation from some sort of professional.
Socket Library on OSX? - akb825 - Dec 6, 2006 10:30 PM
Believe me, many professionals use BSD sockets. I've used them myself, and they are quite easy to use. (and are compatible with Linux and even Windows, with winsock)
Socket Library on OSX? - MacFiend - Dec 6, 2006 11:32 PM
Can you recommend a specific BSD socket class/library for OSX and C++?
I hate to sound picky, but this is what I'm looking for:
1) Automatic handling of all the nifty DNS stuff
2) Installation/compile instructions if it isn't a simple 'make -MACOSX'
3) Documentation and/or tutorials
4) C++ compatability
5) Cross-platform is a plus
If you know of one, please clue me in.
I've been searching all day. I came close a couple of times, but no luck.
Socket Library on OSX? - akb825 - Dec 7, 2006 12:50 AM
I don't know of any C++ classes, but unless you're pressed for time, why not make your own? The C API is pretty straight forward, and it should be relatively easy to make a C++ wrapper to do everything you want. This is the site that I learned all my socket stuff from. The last tutorial on the bottom shows a client and server for over a network, which can be easily adapted to use a custom port etc. Look up the man pages if you want to know more about the specific functions.
Socket Library on OSX? - OneSadCookie - Dec 7, 2006 01:15 AM
Wait, "bigger and brighter" things than Cocoa? And now you want something to do with Carbon? Don't contradict yourself!
Socket Library on OSX? - unknown - Dec 7, 2006 02:02 AM
This is how to use sockets:
Any wrapper library is just going to be more confusing, less well documented and have more bugs.
Ive not seen any wrappers that are worthwhile.
Socket Library on OSX? - MacFiend - Dec 7, 2006 05:20 AM
Like I said, I could write my own socket library easily with CFNetwork; but in keeping with the oft-given advice: why reinvent the wheel? The socket wheel has been invented, right? I just figured there _must_be_ a suitable OSX-compatible C++ BSD sockets library that somebody here at iDevGames could perhaps recommend as to save me weeks of struggling to develop and test my own. All I want is to do some simple networking alongside a C++ library that isn't AppKit compatible, but I'm finding it hard to find a good socket library to use in Carbon.
And what I meant by 'bigger and brighter' was that I've long since stopped focusing on Cocoa and have moved on to a more cross-platform methodology. I didn't mean to flame Cocoa. Sorry if it was taken as such.
So...let me rephrase my question: if anybody out there knows of a decent C++ BSD socket library (or better yet, a CFNetwork C++ class) for OSX, can you please let me know about it? Thanks.
Socket Library on OSX? - KittyMac - Dec 7, 2006 06:24 AM
Perhaps you could elaborate what it is you want this library to provide. I'm with the majority here that you don't need more than sockets or CFNetwork for simple networking, but perhaps your're looking for more? Something to handle concepts of "players" and "games" and such? If so, you might try OpenPlay.
Socket Library on OSX? - MacFiend - Dec 7, 2006 07:56 AM
This was absolutely unnecessary imho: http://www.idevgames.com/forum/showthread.php?p=123329
Socket Library on OSX? - akb825 - Dec 7, 2006 12:38 PM
Writing a socket wrapper shouldn't take weeks. It should take you maybe a day to learn about sockets, knowledge you should probably know anyway for using them, and maybe a few hours to write the actual class.
Socket Library on OSX? - MacFiend - Dec 7, 2006 02:36 PM
Yes, "weeks" was an exaggeration, but you get the idea.
Like I said, I'm just trying to do some simple tests. If nobody wants to give up the goods, then that's fine, I'll just use OpenPlay. :-D
I'm still open to any suggestions for a good OSX compatible C++ BSD sockets library.
Socket Library on OSX? - Frogblast - Dec 7, 2006 08:33 PM
CFNetwork is actually an extremely convenient API to use in a Runloop based program. Why the insistence on a C++ wrapper? Either straight BSD sockets or CFNetwork itself are entirely functional in a C++ program.
It sounds like you're making the 'I'm using c++, and absolutely everything must be an object' mistake. (and it is a mistake).
Socket Library on OSX? - akb825 - Dec 7, 2006 09:11 PM
Agreed about being a mistake to make everything a class. One of my big problems with Java (and similar languages) is forcing you into the OO paradigm, as it's often simpler to leave things in a procedural form. I can see sockets as being able to go either way, though, whether you think the simple integer returned by socket as enough or if you want it encapsulated inside an object that puts the socket into the read/write functions etc. for you. (it's probably a good idea to put a wrapper over those functions, though, so you can handle things like putting in a timeout and having data left over if it took too long to send/receive all of the data; you just have to decide if you want to put it in a function that takes a socket as a parameter or make it part of an object that has a socket in it)
Socket Library on OSX? - MacFiend - Dec 8, 2006 02:46 AM
I've since moved on to actually writing my own BSD socket class. I did my tests with OpenPlay successfuly and now I am satisfied.
Anway, I wasn't looking for a class specifically. Like I stated countless times, I was just trying to do some quick tests. So I was looking for _ANYTHING_ that would permit me to quickly setup networking without having to concern myself with the technical aspects. A class...a library...a magic wand...anything. OO design patterns were the last thing on my mind.
OpenPlay was more than suitable for what I needed. Now that I was able to do my experiments, I was able to see that adding networking is feasible. This is all I wanted to do. If networking wasn't feasible, then I would have wasted days writing and testing my own network code. Am I a bad person for wanting convenience? This is the internet age isn't it?
About the OO thing: that is all subjective. OO-networking may be suitable for one project while it may not be so much so for another. My game engine is highly OO'd and open-ended, so wouldn't it make sense to stay with that design pattern? I really don't know since I've never done networking with C++.
Thanks for your help guys.
Socket Library on OSX? - djork - Jan 24, 2007 10:48 AM
OneSadCookie Wrote:Wait, "bigger and brighter" things than Cocoa? And now you want something to do with Carbon? Don't contradict yourself!
My thoughts exactly