---
title: "Inter Project Communication (IPC)"
canonical: "https://docs.cuesystem.com/space/CVCHELP/512983093/Inter%20Project%20Communication%20(IPC)"
format: markdown
---
> Macro (toc)

---

# IPC limits

- The maximum number of IPC servers open in parallel in one unit is 10.  If the number is exceeded, the _IPCServer.The open command returns False and sets the error to 407.
- The IPC server must be able to process requests and send answers within IPCSendRequestAndReceiveAnswer time out. This timeout can be specified as the value of a parameter called the timeout of the IPCSendRequestAndReceiveAnswer command. If the time out is exceeded command IPCSendRequestAndReceiveAnswer returns False and sets the error to 413.
- The number of IPCSendRequestAndReceiveAnswer commands running in parallel
  - in one unit is **16.**
  - in the appCUE, 12.10.xxx and older is **16**.
  - in the appCUE 12.11.205 – 12.30.xxx is **32.**
  - in the appCUE since version 13.xx is **40**.

# GetUnits

This function finds all units and appCUEs and simulated applications in the Cue Visual Composers on the local network and collects information about them. 

#### Syntax 

```visualbasic
Function GetUnits(ByRef unitsInfo As Array[] As _UnitInfo, ByRef unitsCount As Long) As Boolean
```

unitsInfo 

_<u>UnitInfo</u> It is a destination array that receives information about found units. 

unitsCount 

<u>[Long](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Long)</u> It is the count of valid items in the unitsInfo array content. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing this command. The errors that can happen: <u>[2147483645](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483645)</u>.  

#### Example 

```visualbasic
Var findedunitcount As Long 
Var counter As Long:= 1 
Var dstarray[30] As _UnitInfo 

GetUnits(dstarray, findedunitcount) 

Do While counter <= findedunitcount 
  DebugPrint(dstarray[counter].ProductName) 
  Counter += 1 
End Do
```

# IPCIsAlive

This function checks if another unit is available and checks if another unit has an open IPC communication channel. Destination units could be from different projects or the same project.  

#### Syntax 

```visualbasic
Function IPCIsAlive ( 
  magicnameoripaddress As Text, 
  protocolname As Text, 
  instancename As Text, 
  password As Text,  
  Optional timeout As Time := 10.0)
As Boolean
```

#### Parameters 

magicnameoripaddress 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Magic name or IP address of destination unit. 

protocolname 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the protocol used by destination instance of IPCserver.  

instancename 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the instance of the IPC server which is to receive and answer this request.  

password 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Password which is to be used for communication with the destination instance of IPCserver. 

timeout 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> Total timeout for connection and for checking if the IPC communication channel is open. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs.  

The function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[99](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#99)</u>, <u>[226](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#226)</u>, <u>[401](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#401)</u>, <u>[402](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#402)</u>, <u>[404](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#404)</u>, <u>[410](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#410)</u>, <u>[413](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#413)</u>, <u>[2147483645](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483645)</u>,  <u>[2147483646](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483646)</u>.  

# IPCSendRequestAndReceiveAnswer

This function sends a request to another unit and waits for an answer. Destination units could be from different projects or the same project.  

#### Syntax 

```visualbasic
Function IPCSendRequestAndReceiveAnswer ( 
  magicnameoripaddress As Text, 
  protocolname As Text, 
  instancename As Text, 
  password As Text, 
  requestname As Text, 
  requestdata As Text, 
  ByRef answer As Text, 
  Optional timeout As Time := 10.0)
As Boolean
```

#### Parameters 

magicnameoripaddress 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Magic name or IP address of destination unit. 

protocolname 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the protocol used by destination instance of IPCserver.  

instancename 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the instance of the IPC server which is to receive and answer this request.  

password

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Password which is to be used for communication with the destination instance of IPCserver. 

requestname 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the request.  

requestdata 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Request data. 

answer 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Received an answer.  

timeout 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> Total timeout for connection, for sending requests, and for receiving answers. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs.  

The function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[99](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#99)</u>, <u>[226](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#226)</u>, <u>[401](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#401)</u>, <u>[402](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#402)</u>, <u>[404](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#404)</u>, <u>[410](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#410)</u>, <u>[412](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#412)</u>, <u>[413](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#413)</u>, <u>[2147483645](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483645)</u>,  <u>[2147483646](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483646)</u>.  

This function returns False also if the error answer (sent by command SendErrorAnswer) was received. In such a case the function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> would return <u>[412](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#412)</u>.  

# _IPCServer

This class can receive commands and send answers via the inter-project communication system. 

# Open

Opens communication channel. 

#### Syntax 

```visualbasic
Function Open(protocolname As Text, instancename As Text, password As Text) As Boolean
```

#### Parameters 

protocolname 

<u>The text</u> Name of the protocol is used by this instance of the IPC server 

instancename 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of this instance of IPC server. (Can be the empty text ””.) 

password 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Password which is to be used for communication with this IPC server. (Can be the empty text ””.) 

Note that the above-mentioned parameters are to be used in the command IPCSendRequestAndReceiveAnswer to address this IPCserver. 

#### Return value 

<u>[Boolean](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Boolean)</u> It is True on success or False if an error occurs. The function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[406](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#406)</u>, <u>[407](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#407)</u>, <u>[2147483645](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483645)</u>.  

# Close

This command closes opened communication channel. 

#### Syntax 

```visualbasic
Function Close()
```

# ReceiveRequest

*This command is to be used to receive a request which was sent from the sender unit by IPCSendRequestAndReceiveAnswer. *

#### Syntax 

```visualbasic
Function ReceiveRequest (ByRef srcmagicname As Text, ByRef requestname As Text, ByRef requestdata As Text, Optional timeout As Time := _TIME_INFINITE) As Boolean
```

#### Parameters 

srcmagicname 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Magic name of sender unit. 

requestname 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Name of the request.  

requestdata 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Request data. 

timeout 

<u>[Time](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Time)</u> Time to wait for request reception. 

#### Return value 

<u>Boolean</u> It is True if any request is received or False otherwise. The function <u>[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)</u> returns the error number that occurred while executing the command. The errors that can happen: <u>[92](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#92)</u>, <u>[400](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#400)</u>, <u>[411](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#411)</u>, <u>[2147483645](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483645)</u>, <u>[2147483646](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#2147483646)</u>.  

# SendAnswer

*This command is to be used to send answers as a response to a request which was received by ReceiveRequest.  *

#### Syntax 

```visualbasic
Function SendAnswer(answer As Text)
```

#### Parameters 

answer 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Answer data.  

# SendErrorAnswer

*This command is to be used to send error answers as a response to a request which was received by ReceiveRequest. It causes the IPCSendRequestAndReceiveAnswer command on the sender to return False and  *<u>*[GetLastError](/wiki/spaces/CVCHELP/pages/510525445/Command+errors#GetLastError)*</u>* would return *<u>*412*</u>*.  *

#### Syntax 

```visualbasic
Function SendErrorAnswer(answer As Text)
```

#### Parameters 

answer 

<u>[Text](/wiki/spaces/CVCHELP/pages/495058958/Data+types#Text)</u> Error answer data.  

# Structure _UnitInfo

This structure is predefined in the firmware of all units, which supports functions with _UnitInfo. If item IsSimulated is True it is not a unit or an appCUE but it is an application simulated in some Cue Visual Composer on the local network.   

```
Global Structure _UnitInfo  
  Var ProductName As Text[50] 
  Var ProductCode As Text[6] 
  Var HWRevision As Long 
  Var SerialNumber As Long 
  Var FirmwareVersion As Text[10] 
  Var IPAddress As Text[42] 
  Var MagicName As Text[128] 
  Var IsSimulated As Boolean 
End Structure
```

***Inter project communication example**** *

#### IPC client  

```visualbasic
// Sender example 
Function SendIPCMsg(destination As Text, requestname As Text, requestdata As Text) 
  Var answer As Text[100] 
  Var err As Long 

  If IPCSendRequestAndReceiveAnswer(destination,"Light.Example.Protocol", "Light1", "somepassword", requestname, requestdata, answer,:10) = True Then 
    DebugPrint(answer) 
  Else 
    err := GetLastError()  
    If err = 412 Then 
      DebugPrintFormat("Error {t}", answer) 
    Else 
      DebugPrintFormat("Error {n}", err) 
    End If  
  End If 
End Function 

Private Process Autoexec() 
  Wait(:1) 
  SendIPCMsg("ExampleServer","SwitchOn","") 
  Wait(:1) 
  SendIPCMsg("ExampleServer","SwitchOff","")  
End Process
```

#### IPC server 

This example supposes that the Magic name in this unit is set to **ExampleServer **(in the Cue Visual Composer Configuration and also in a unit)**.**   

```visualbasic
// ExampleServer example 
Private Process IPCReceiverLoop() 
  Var ipcServer As _IPCServer 
  Var ok As Boolean 
  Var srcmagic As Text[128] 
  Var requestname As Text[128] 
  Var requestdata As Text[200] 
  Var err As Long 
  
  ipcServer.Open("Light.Example.Protocol", "Light1", "somepassword") 

  Do 
    ok := ipcServer.ReceiveRequest(srcmagic, requestname, requestdata) 
    If ok Then  
      Select requestname 
        Case "SwitchOn" 
          DebugPrint("SwitchOn received")  
          ipcServer.SendAnswer("OK") 
        Case "SwitchOff" 
          DebugPrint("SwitchOff received")  
          ipcServer.SendAnswer("OK") 
        Case Else  
          ipcServer.SendErrorAnswer("Unknown requestname") 
      End Select 
    Else 
      err := GetLastError() 
      DebugPrintFormat("ReceiveRequest error {n}", err) 
    End If 
  End Do 

  ipcServer.Close() 
End Process 
 
Private Process Autoexec()  
  StartProcess IPCReceiverLoop() 
End Process
```