# socketConnect

## Description

Creates a TCP connection through a socket.

## Input / Parameter

| Name          | Description                           | Input Type  | Default | Options | Required |
| ------------- | ------------------------------------- | ----------- | ------- | ------- | -------- |
| type          | The type of connection.               | String/Text | -       | -       | Yes      |
| name          | The name of the connection.           | String/Text | default | -       | No       |
| host          | The host for the connection.          | String/Text | -       | -       | Yes      |
| port          | The port for the connection.          | String/Text | -       | -       | Yes      |
| authorization | The authorization for the connection. | String/Text | -       | -       | Yes      |

## Output

N/A

## Callback

### callback

The function to be executed if the connection is created successfully.

### errorCallback

The function to be executed if the connection is not created successfully.

## Video

Coming Soon.

## Example

The user wants to create a connection and view the socket input if it is successful.

### Steps

1. Drag a button and label component to a page in the mobile designer. Call the function `socketConnect` in the button component.

   ![](/files/LI9VLwNngz5oDXBBzSTo)

   ![](/files/K8dL8lh7bn4qzLdfzhk3)
2. Call the function `console` in the callbacks of the `socketConnect` function. Select the parameter type `input` for the `value` parameter.

   ![](/files/S4NapjilwhR74Xg7lIKc)
3. Call the function `setComponentValue` and select the label component in the `component` parameter. Set the `value` parameter type to `input`.

   ![](/files/NhYoZIcDfhwumIgYG9sW)

   ![](/files/u1nGnYpzJyUbnGsgw85M)

### Result

If the socket connection is successful, the host name will be shown in the label component.

![](/files/CBDU3DNCsddpFuJi7RQz)

## Links


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/device/socketconnect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
