0

I am using SwiftyZeroMQ in iOS for zeromq. I can connect and communicate via sockets. But issue is I can't find anyway to know how can I get event/status that socket connection has failed?

like let result = zmq_connect(handle, endpoint) always return 0 in result

Haris
  • 1,822
  • 2
  • 22
  • 44
  • Checking the result is the correct way. However ZeroMQ socket are not plain (TCP/IP) sockets. `zmq_connect` usually succeeds because it does not need the peer to be reachable. ZeroMQ sockets will connect (and reconnect) when needed, for example when you start sending or receiving data. – rveerd May 11 '22 at 10:13

1 Answers1

-1

…how can I get event/status that socket connection has failed?

The first step is to forget everything about native-sockets, as ZeroMQ Socket()-instances are different.

To start understanding the concept, perhaps start here to get the global view of the composition of:

  • what is the Scalable Formal Communications (behavioural pattern) Archetype
  • what is the engine - the actual signalling/messaging serving Context()
  • what is the AccessPoint (to be .bind()-exposed to public and so .connect()-ed as & when needed)

Having got these abstractions, one soon realises the real-world applications seldom rely on just one pattern, most often there are many, app-level cooperating (possibly also in many-to-many topologies) connections, like noted here

Last, but not least, there are low-level details we may source from our abstracted Scalable Formal Communication Archetypes' AccessPoints, if using a ZeroMQ API documented socket_monitor() and set it up so as to feed many low-level events we normally do not want to see in production. ZeroMQ API documentation is instrumental in how to do this, yet your iOS-specific native-API binding may, yet need not, cover this in your current language-binding, so start first with the SwiftyZeroMQ documentation, if it covers also this ZeroMQ native-API functions.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
user3666197
  • 1
  • 6
  • 50
  • 92