> For the complete documentation index, see [llms.txt](https://docs.emobiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/device/socketconnect.md).

# 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.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-8ff44dc3e3e174b37d10e3019868c77d61566608%2FsocketConnect-step-1.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-a314bb960c3e607d8c62289688efc692b08b8e13%2FsocketConnect-step-2.png?alt=media)
2. Call the function `console` in the callbacks of the `socketConnect` function. Select the parameter type `input` for the `value` parameter.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-d2344cb6959c66e540764f6e32168a452e08bd76%2FsocketConnect-step-3.png?alt=media)
3. Call the function `setComponentValue` and select the label component in the `component` parameter. Set the `value` parameter type to `input`.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-ff0578fc1443bf2dfbeb7ccf3f2274e10ed53bf6%2FsocketConnect-step-4.png?alt=media)

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-b339d9c93b6d78a3e6a5f481fd998bd50c016419%2FsocketConnect-step-5.png?alt=media)

### Result

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

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c2a577d9d66d32f7abfc699e1ec7b5805e8977ef%2FsocketConnect-result-1.jpg?alt=media)

## Links
