简体   繁体   中英

Send TCP message from dot net server to my iOS device using ip and port

Since I'm an iOS developer and not a dot net developer, I'm trying to achieve a way to send messages thru TCP from server to iOS devices. I saw a few codes in C# with ip and port, but how can I figure out which port shall I use and if it's even possible?

Not sure if I understood your question.

First you need to have a Socket server that's listening to a port and interface(s). Then you need a iOS socket client that will connect to the server ip:port.

I'd use the port 80 or 443 in order to avoid network restrictions. If you want to use a TCP approach, instead for instance http, you will need a application level protocol.

Give a look to 0MQ ( http://zeromq.org/ ) as there's port to iOS client and c#. The documentation is really good, loads of examples, very fast and in my opinion a beautiful think :)

Nevertheless, I'd run away from WCf and I would try to use HTTP if possible with WebAPI or ServiceStack.

In .NET the Windows Communication Foundation (WCF) is the flagship of network and web services. You can expose services over HTTP, TCP, and other protocols. In regard to TCP, the NetTcpBinding is what you want. In the service configuration you specify the endpoint address (URI), the binding, and the service contract with the client uses to create a proxy. You also specify the data types (data contracts) that the service works with.

The NetTcpBinding comes with transport security, reliability, and more, so it is the preferred binding for Intranet services.

WARNING: WCF is not simple to learn or implement, and I have known web service developers who were very unhappy during the transition to WCF.

The only concern I would have is how well the NetTcpBinding would interop with the iOS client? We utilize handheld motorola devices, and they only support basic HTTP web services. In fact, I am almost certain the NetTcpBinding will not work with an iOS client, but I could be wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM