views:

49

answers:

3

What is the simplest way (preferably without using third party frameworks) in objective c, to setup a simple server that listens for socket connections, and reads data from the clients on a line by line basis.

ie Ideally you would just need to create an instance of a "server" object, that would pass "client" objects back to which receive incoming data messages.

+1  A: 

Well, there are classes out there, with which, in a couple of lines of code, you could write a simple socket server.

For eg, search for TcpListener() on Google and see if that works for you. I am sure there are examples for Java as well.

feroze
Thanks feroze, but I am doing objective-c, I did tag as objective-c, maybe I should have put it in the question as well. (The subject line was already getting really long)
corydoras
+2  A: 

Have a look here How to Write a Cocoa Web Server

Maybe not the simplest solution but it gives a good insight of needed logic for a server

epatel
I was hoping cocoa, or some other framework can take care of most of the work and just pass on actual connections to my code (:
corydoras
A: 

This question has been open for a long time. There appears to be no standard way to do this. I ended up just writing my own Objective C code to wrap C

There are some other "libraries" out there, but I find a couple of .m and .h files much easier to work with than tracking some third party library thats big and complicated and possibly has undiscovered bugs in features I don't want to use anyway.

corydoras