<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Port/DidBecomeInvalidMessage",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So6NSPortC10FoundationE23DidBecomeInvalidMessageV"
  },
  "title" : "Port.DidBecomeInvalidMessage"
}
-->

# Port.DidBecomeInvalidMessage

A message the system sends when a port becomes invalid.

```
struct DidBecomeInvalidMessage
```

## Overview

A [`SocketPort`](/documentation/Foundation/SocketPort) object can’t detect when its connection to a remote port is lost, even if the remote port is on the same machine.
Therefore, it can’t invalidate itself and post this message.
Instead, your app needs to detect the timeout error when sending the next message.

The [`Port`](/documentation/Foundation/Port) object sending this message is no longer useful, so all receivers should unregister themselves for any notifications involving the port.
The handler that receives this message should check to see which port became invalid before attempting to do anything.
In particular, observers that receive all `DidBecomeInvalidMessage` instances should be aware that the system handles communication with the window server through a `Port`.
If this port becomes invalid, drawing operations cause a fatal error.

Observe this message with the identifier [`didBecomeInvalid`](/documentation/Foundation/NotificationCenter/MessageIdentifier/didBecomeInvalid), or specify its type directly to the `addObserver(of:for:using:)` method.
The [`Subject`](/documentation/Foundation/NotificationCenter/MainActorMessage/Subject) of this message type is [`Port`](/documentation/Foundation/Port).

This message interoperates with the notification [`didBecomeInvalidNotification`](/documentation/Foundation/Port/didBecomeInvalidNotification).
The system notifies observers of the message when the [`NotificationCenter`](/documentation/Foundation/NotificationCenter) posts the notification.
Similarly, the system notifies observers of the notification when it posts the message.

## Topics

### Creating a message

[`init()`](/documentation/Foundation/Port/DidBecomeInvalidMessage/init())

Creates a message that indicates a port became invalid.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`AsyncMessage`](/documentation/Foundation/NotificationCenter/AsyncMessage)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)