-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0187d7b
commit ec2d606
Showing
3 changed files
with
42 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@bunny.net/edgescript-sdk": minor | ||
--- | ||
|
||
Consider the fact we can have a TcpListener with no associated Addr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,27 @@ | ||
import { IPv4 } from "./ip.ts"; | ||
|
||
export type SocketAddr = { | ||
export type SocketAddr = SocketAddrV4 | NoAddr; | ||
|
||
export type SocketAddrV4 = { | ||
readonly _tag: "SocketAddrV4", | ||
port: number, | ||
ip: IPv4, | ||
}; | ||
|
||
export type NoAddr = { | ||
readonly _tag: "NoAddr", | ||
}; | ||
|
||
/** | ||
* Returns the port number associated with this socket address. | ||
*/ | ||
export function port(addr: SocketAddr): number { | ||
export function port(addr: SocketAddrV4): number { | ||
return addr.port; | ||
} | ||
|
||
/** | ||
* Returns the IP address associated with this socket address. | ||
*/ | ||
export function ip(addr: SocketAddr): IPv4 { | ||
export function ip(addr: SocketAddrV4): IPv4 { | ||
return addr.ip; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters