@@ -48,6 +48,7 @@ final class SocketTests: XCTestCase {
4848 IPv4Protocol . tcp,
4949 bind: address
5050 )
51+ XCTAssertEqual ( try server. fileDescriptor. address ( IPv4SocketAddress . self) , address)
5152 defer { Task { await server. close ( ) } }
5253 NSLog ( " Server: Created server socket \( server. fileDescriptor) " )
5354 try server. fileDescriptor. listen ( backlog: 10 )
@@ -58,6 +59,7 @@ final class SocketTests: XCTestCase {
5859 fileDescriptor: try await server. fileDescriptor. accept ( )
5960 )
6061 NSLog ( " Server: Got incoming connection \( newConnection. fileDescriptor) " )
62+ XCTAssertEqual ( try newConnection. fileDescriptor. address ( IPv4SocketAddress . self) . address. rawValue, " 127.0.0.1 " )
6163 let _ = try await newConnection. write ( data)
6264 NSLog ( " Server: Wrote outgoing data " )
6365 } catch {
@@ -69,13 +71,15 @@ final class SocketTests: XCTestCase {
6971 let client = try await Socket (
7072 IPv4Protocol . tcp
7173 )
74+ XCTAssertEqual ( try client. fileDescriptor. address ( IPv4SocketAddress . self) . address, . any)
7275 defer { Task { await client. close ( ) } }
7376 NSLog ( " Client: Created client socket \( client. fileDescriptor) " )
7477
7578 NSLog ( " Client: Will connect to server " )
7679 do { try await client. fileDescriptor. connect ( to: address, sleep: 100_000_000 ) }
7780 catch Errno . socketIsConnected { }
7881 NSLog ( " Client: Connected to server " )
82+ XCTAssertEqual ( try client. fileDescriptor. address ( IPv4SocketAddress . self) . address. rawValue, " 127.0.0.1 " )
7983 let read = try await client. read ( data. count)
8084 NSLog ( " Client: Read incoming data " )
8185 XCTAssertEqual ( data, read)
0 commit comments