Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to listen on a network port in Objective-C

I am trying to make an application for iPhone that can listen for traffick on a specific network port.

A server on my network is sending out messages (different status messages for devices the server handles) on a specific port.

My problem is that when I make a thread and makePairWithSocket I block the port for others who want to send messages to the server, so I only want to listen to the traffic on a specifyed port and then check for specific heraders and then use those messages. I know how to make the connection and talk to the server using write and read streams, but then I makePairWithSocket and block the port for all other devices on the network

Any one that has any suggestions on how to listen on a port in Objective-C without pairing with the server?

Thanks in advance Daniel

like image 445
KungWaz Avatar asked Oct 14 '22 00:10

KungWaz


1 Answers

Check out CocoaAsyncSocket. It gives you a nice and structured way (with delegates) to send and receive data... also with multiple clients. The documentation is quite good. project link

edit: Have a look at the AsyncUdpSocket class for a stateless UDP connection.

like image 113
Felix Avatar answered Nov 01 '22 13:11

Felix