# The Python IoTCommunicator Constructor

Create an IoTCommunicator instance with a list of optional parameters.

### For an overview see page Python IoTCommunicator Class

### Prototype

        IoTCommunicator(comm_params, on_connect, on_recieve, on_ack, on_disconnect, on_destroy)

### Arguments

comm_params | When specified, a dictionary is expected with the following optional keys:
"n_callback_threads" | The number of threads to process incoming requests; default value is 8 (integer)
"sock_domain" | A flag defining the socket domain
"ssl_params" | A dictionary with SSL parameters
"send_timeout" | The timeout value for network `send` (integer)
"recv_timeout" | The timeout value for network `recv` (integer)
"listen_queue_size" | The maximum length of the listen socket queue; default value is 0 (which means use a system-defined maximum) (integer)
"wakeup_port" | The port number for the service port; default value 0 (means use a system-defined port number (integer)
on_connect | The callback for the `on_connect` event; a callable Python procedure is expected with the following signature:
      def iot_on_connect(iotc):
        pass

      ...

      comm.on_connect = iot_on_connect
where `iotc` is an IoTCommunicator object
on_recieve | The callback for the `on_receive` event; a callable Python procedure is expected with the following signature:
      def iot_on_receive(iotc):
        pass

      ...

      comm.on_receive = iot_on_receive
where `iotc` is an IoTCommunicator object
on_ack | The callback for the `on_ack` event; a callable Python procedure is expected with the following signature:
      def iot_on_ack(iotc, ack):
        pass

      ...

      comm.on_ack = iot_on_ack
where `iotc` is an IoTCommunicator object and `ack` is a dictionary describing the `ack` event with the following keys:
"seq" | This is used internally in the `mco_iot_replicator_sync()` API function to implement the `MCO_IOT_SYNC_WAIT` mode.(long)
"sender_agent_id" | The `agent_id` of the sender (long)
"receiver_agent_id" | The `agent_id` of the receiver (long)
"timestamp" | The time of the acknowledgment (long)
"error_code" | The error code if not null (integer)
on_disconnect | The callback for the `on_diconnect` event; a callable Python procedure is expected with the following signature:
      def iot_on_disconnect(iotc):
        pass

      ...

      comm.on_disconnect = iot_on_disconnect
where `iotc` is an IoTCommunicator object
on_destroy | The callback for the `on_destroy` event; a callable Python procedure is expected with the following signature:
      def iot_on_destroy(iotc):
        pass

      ...

      comm.on_destroy = iot_on_destroy
where `iotc` is an IoTCommunicator object

### Description

This constructor creates an instance of IoTCommunicator with the specified parameters.

### Returns

IoTCommunicator | The IoTCommunicator object was instantiated successfully
Exception | An exception is thrown with the appropriate error message