How to create a TCP socket using Objective-C, check if some TCP ports are opened on the server?
I tried using some tutorials but none worked, because I need to create a server using an IP (198.168.0.000) and not a site, such as paypal.com, as some blog posts use.
I'm a little confused about which class to use and how to use. I know that is not the best place to ask, but do not know where to search.
Thank you for your help!
I recommend CocoaAsyncSocket for this kind of work. You can do it by hand, but if you're working in ObjC, then CocoaAsyncSocket is a much nicer interface.
I would recommend you to take a look at NSStream and its subclasses NSInputStream and NSOutputStream.
To check for connectivity you may also consider to take a look at Reachability.
Besides Objective-C is a superset of C, so you can always rely on C structs/functions to create sockets (Beej's guide to network programming)
Starting with Apple's documentation is often a good idea. Read Setting Up Socket Streams in Stream Programming Guide. With that under your belt, even if you decide to go with a third party library you'll have a pretty good idea of what it's doing under the covers.
You have a few API choices on iOS for network sockets. If you have code to an existing BSD socket unix server that does what you want, I would create a secondary thread and just use the existing code on that thread. The best instructions for using BSD sockets is Unix Network Programming by Stevens.
If it's new code that runs on iOS only, I agree with Rob Napier that CocoaAsyncSocket is a reasonable way to go.