> For the complete documentation index, see [llms.txt](https://docs.dbnetsoft.com/dbnetsoft/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dbnetsoft.com/dbnetsoft/screenspro/sources/tcp-udp-serial.md).

# TCP/UDP/Serial

This source receives lines from a TCP, UDP or serial connection and cuts every line it receives into named fields. It is made for timing devices and display boards, which send a line per event in a fixed column layout.

## Settings

| Setting  |            |                                                        |
| -------- | ---------- | ------------------------------------------------------ |
| Port     | Connection | The connection itself, see below.                      |
| Mappings | List       | The fields every received line is cut into, see below. |

Name and Enabled are described on the [Sources](/dbnetsoft/screenspro/sources.md) page.

### Port

`Layer` decides what kind of connection is opened, and the settings belonging to that layer are filled in below it:

| Layer         | Settings used                   |
| ------------- | ------------------------------- |
| `TcpClient`   | Remote host and remote port.    |
| `TcpServer`   | Local port that is listened on. |
| `UdpReceiver` | Listening port.                 |
| `UdpSender`   | Remote host and port.           |
| `Serial`      | Port name and baud rate.        |

`Serialization` has to stay on `Lines`: the source only reacts to complete lines, and `LineEnd` decides where a line ends, a carriage return by default.

### Mappings

Every mapping cuts one field out of the received line:

| Setting |        |                                                                 |
| ------- | ------ | --------------------------------------------------------------- |
| Name    | string | The name the field is bound with.                               |
| Offset  | int    | Position of the first character of the field, counted from `0`. |
| Length  | int    | Number of characters the field is long.                         |
| Trim    | bool   | Removes the spaces before and after the field.                  |

## Properties

| Property |        |                                                                |
| -------- | ------ | -------------------------------------------------------------- |
| Line     | string | The complete line as it was received.                          |
| Mappings | object | The fields of that line, addressed by the name of the mapping. |

This source does not fill `Value`; the fields are read from `Mappings`.

## Example

A timing device sends lines like this one:

```
0123 SMITH JOHN        12:34.56
```

Three mappings cut it into bib number, name and time:

| Name   | Offset | Length | Trim |
| ------ | ------ | ------ | ---- |
| Bib    | 0      | 4      | yes  |
| Runner | 5      | 18     | yes  |
| Time   | 23     | 8      | yes  |

With the source named *Timing*, the fields are bound like this:

```xml
<controls:TextElement Text="{Binding Sources.Timing.Mappings.Bib}" />
<controls:TextElement Text="{Binding Sources.Timing.Mappings.Runner}" />
<controls:TextElement Text="{Binding Sources.Timing.Mappings.Time}" />
```

The complete line is always available as `{Binding Sources.Timing.Line}`, which helps while the offsets are still being set up.
