Reputation: 405
hopefully someone can give me a minimal working example of opening a socket, sending a command ans receiving the answer.
In php I would use this code:
$socket = getsock('127.0.0.1', 4028);
socket_write($socket, $cmd, strlen($cmd));
$line = readsockline($socket);
socket_close($socket);
In $line I will receive the answer from the socket's target. How would I accomplish that in objective-c (and yes, I have taken a look at apple's docs but I couldn't find/understand the way to send and receive commands correctly).
Thank you :)
Upvotes: 0
Views: 214
Reputation: 162712
Trying to convert code line by line from one system to another doesn't really work. You need to understand how the target system is architected and what is expected of your code first.
Specifically:
Then, you'll need to decide if you want to run your request asynchronously (most likely) or synchronously on a background thread (unlikely).
From there, you'll probably want to leverage the URL loading infrastructure provided by the NSURLConnection class.
Upvotes: 1