> For the complete documentation index, see [llms.txt](https://docs.atsign.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.atsign.com/atsdk/atsdk-walkthroughs/atsdk-tutorial/send-and-receive-data-synchronously.md).

# Send and Receive data synchronously

## Sending and receiving data in near real-time

Sending data, as we saw in the previous example, is pretty easy, but the receiver would have to continually poll unless we had a mechanism to notify the receiving Atsign that they had data to deal with. Fortunately, we have just that with atNotifications.

A notification can be sent to an Atsign and if that Atsign is listening for it, it will create an event that can be handled as soon as the notification is received.

To receive we can use code like this:

```dart
  atClient.notificationService
      .subscribe(regex: 'message.$nameSpace@', shouldDecrypt: true)
      .listen(((notification)
```

And to send code like this:

```dart
  await atClient.notificationService.notify(
      NotificationParams.forUpdate(sharedRecordID, value: message));
```

There are two examples in the repo `at_notify_receive.dart` and `at_notify_send.dart` both contain the basics to send and receive synchronously.&#x20;

To test for yourself, you will need two terminal windows. To do that, you can press the split button on the VS Code IDE.

<figure><img src="/files/xDyGDbn4zpx5vhCg2ybX" alt=""><figcaption></figcaption></figure>

You can then run the following commands again note to replace the Atsigns with your own.

In the right window, run this first to receive:

```dart
dart run .\bin\at_notify_receive.dart -a "@energetic22" -n "atsign"
```

In the left window, you can now send a message using:

```dart
dart run .\bin\at_notify_send.dart -a "@7capricorn" -n "atsign" -o "@energetic22" -m "hello world"
```

The net result should look like this, and your message should appear in the right-hand side.&#x20;

<figure><img src="/files/L9ifZAQGoO23UTGedZoR" alt=""><figcaption><p>Message received.</p></figcaption></figure>

You can try sending different messages and make sure they arrive, you can also put Dart on another machine and talk from machine to machine without setting up any other infrastructure.&#x20;

Neither the sender nor the receiver need any TCP ports open, so this can be used to send end-to-end encrypted messages in near real-time without VPNs/Firewalls being required, just access to the Internet.

If you are thinking this is the basis of a simple end-to-end encrypted chat application, that's coming soon with at\_talk.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.atsign.com/atsdk/atsdk-walkthroughs/atsdk-tutorial/send-and-receive-data-synchronously.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
