开发者

Approach for Client-Server Communication in Objective-C / Cocoa

开发者 https://www.devze.com 2023-01-09 19:06 出处:网络
I am working on an application for OS X that needs communication of small bits of data between a server side application and a client side application. I tried using a Ruby on Rails server as a backen

I am working on an application for OS X that needs communication of small bits of data between a server side application and a client side application. I tried using a Ruby on Rails server as a backend way of communicating data, which was very simple and easy to implement but caused a bit of issues (I am not a proficient Ruby developer). I want to try to use sockets (NSSocketPort or CFSockets) but am not sure if those are the best ways to tackle the issue. The information I need to transmit is stuff like the client's machine's name, client's network's bandwidth, and other small bits on info (text). Also, another thing to note is that all of the communication will be on the same (hopefully closed) network. If someone can make a helpful and simple recommendation with links for more information, I would appreciate it tremendously! Thanks!

EX. If I had a bunch of clients and wanted to display a list of them, what would be the best approach? There is an application running somewhere on the network, which is to display a list of the clients, and all of the clients have the IP address to the开发者_如何学运维 machine with that application running. I want to be able to display a new client on the screen every time a client sends a message to that application. I assumed that using HTTP requests would cause me to have to poll using GETs and display a list every time something new is added. I'd like to be able to call a method instead every time a message is received by something running in the background.


Is there some reason to not use simple HTTP?

Use HTTP POST to send information from the client to server and GET to retrieve information from the server. If it's little bits of text information, HTTP with JSON encoding should be sufficient for all your needs. If you need security, you get that with HTTPS.

0

精彩评论

暂无评论...
验证码 换一张
取 消