Network connections send and receive data using transport and security protocols.

Posts under Network tag

200 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Read user defined network interface names
Hi, I have a C++ application on OSX that normally works on systems with multiple network interfaces and I'd like to offer a dialog to the users to select the appropriate NIC for the different tasks. It would be fine to show the users the name they assigned to the NIC inside the system settings but I don't know how to read these names. I tried to use SCNetworkInterfaceGetLocalizedDisplayName() but that only gives me the name before I entered my own user defined name (something like "USB 10/100/1000 LAN"). Is there a way to read the user defined name of each NIC? Thanks and best regards, Johannes
3
0
550
Dec ’23
How to configure settings to enable communication with the AppStore Watched post
premise We are planning to use self-produced App (published in AppStore) which is installed on our iPad in a closed network. We will implement the update of the app automatically. Question In order to allow the automatic update of the app in AppStore, do we need to allow communication with servers or domains? If it is a case, could you tell us the port number for this connection?
0
0
243
Dec ’23
Debug Version works, Released App Store version does not...
I'm slowly getting angry here... We wrote two different versions of our app in flutter for android, both worked seamlessly at the first try within 7 Days. Me and my brother are trying to get apple to work for over a year now. It's so freaking frustrating... Our Debug version is able to send UDP packets to our Word Clock, but when the app is released to the store, none of my two iphones (14 and XR) is able to send UDP packets successfully. (Configuring the wordclock). As is understand the techical background, there is no way for me to find the error, because the debug version, i use to DEBUG the app, works fine. Can anyone help here?... Is there a known topic, i should have a look on? Is there a way for me to find the error? Thank you and best regards Tobias
1
0
473
Dec ’23
Implementing Client and Server over UDP based custom protocol using Network Framework
We have an application design where, every instance (process) is acting as a UDP server as well as UDP client, using the same UDP port: to listen & respond (as a server) to multiple destinations as well to send (as a client) to multiple destinations. This considering the implicit nature of UDP being connectionless. At any given point in time, I would be, as a server, talking to many clients and as a client, talking to many servers. We were using BSD sockets for the purpose across all our target platforms including Apple Kernel (macOS, iOS, iPadOS, tvOS, watchOS etc.). Then we learnt about limitation on watchOS, where we started exploring 'Network Framework' as an alternative to BSD sockets on watchOS (or even others on Apple Kernel). This is to understand, how can we achieve the same (if at all) using 'Network Framework'? Process A [To act as UDP server] We will have NWListener on inaddrany, local port X, using UDP Does it implicitly work for both IPv4 and IPv6 incoming data? In case of BSD sockets, we would have created two sockets - one bound on INADDR_ANY and other on in6addr_any. Does in case of NWListener, also internally it creates two sockets - one for IPv4 and other for IPv6? For every incoming data from a client (which may not be on Apple Kernel and hence not using NWConnection), a NWConnection would be created on this UDP server (off course, if NWConnection does not already exist for the same local and remote IP/Port). Just for our clarity: An underlying socket is not created (like it would have in case of TCP)? The underlying data exchange between the UDP clients and this UDP server would happen on the same socket bound on port X? NWConnection for UDP is more a logical construct created to represent a “UDP flow”, that is, a sequence of datagrams, including both inbound and outbound, that share the same local IP / port and same remote IP / port tuple, where for 'local IP/Port', there would a socket bound on it internally. I can use the same NWConnection to respond (send data) back to the client. Since UDP is connectionless, how do we manage the lifecycle of these NWConnection(s) getting created? Though there is no socket resource to be freed per NWConnection basis BUT there must be some other system resources like memory being occupied. We understand that once cancelled, if we receive a datagram from the same client (actually, on the same UDP flow), the listener will create a new connection. [To act as UDP client] We will have to create a NWConnection to a UDP server We would like to have that NWConnection internally use the same local port X to send data to the remote UDP server, is that possible? The interface to init NWConnection seem to only take remote endpoint as an input and protocol as an input. And this we would like to do for all UDP servers we want to connect as client? Which would mean multiple NWConnection - one for each UDP Server we want to communicate to BUT same local port X is being used on the UDP Client. I will receive the response from the Server also on the same NWConnection (if still active and not cancelled). The client cancels the NWConnection when no more intends to talk to the same UDP Server.
3
0
434
Dec ’23
How can we create a BSD socket that binds on *.*, PortX and udp46?
One: does it involve below or any other steps? Create a socket (AF_INET6, SOCK_DGRAM, IPPROTO_UDP) Bind it to AF_INET6, in6addr_any, port X. Disable IPV6_V6ONLY using setsockopt. Second: If answer to above is yes, in other operating system, if a datagram would have got received over IPv4, it would have lead to IPv4-mapped IPv6 address in the recvfrom call and protocol would have been considered udp6. Third: is UDP46 only supported by Apple Kernel (is it not a POSIX standard behaviour) and also within Apple Kernel - not supported on all versions? Why this question? We created a NWListener on a local port, using udp and when we ran a 'netstat -an -p udp', it showed protocol as 'udp46'
1
0
287
Dec ’23
Networking to/from application locked to 127.0.0.1
It will only use 127.0.0.1 no matter which technique is used to executed it - even in the IDE debugger. And it changes the listener port. This is not related to the trust execution system, so I recommend that you start a new thread for it. Tag it with Network so that I see it. This is a local or optionally a client/server application that uses multiple TCP/IP protocols. If it's not the "trust" system what is altering the IP addresses and ports and why? What is the procedure to get the application to operate as designed? Is this related to not having a Developer ID and certificate (yet)?? Still evaluating whether the application can be made to work well on macOS and whether the complications involved are worth the time, money and effort for an Open Source project. Further, am concerned that Apple may decide they don't like this application and not allow it to be validated, or whatever, to install and run. Am completely unfamiliar with Apple's policies and procedures when making those decisions. But, from what I've read recently, that has been an issue for some developers. Would you have any guidance regarding that? Again, thank you very much for your time.
10
0
664
Jan ’24
NWConnection UDP Broadcast not sent out correctly
Problem I am trying to send out a broadcast using NWConnection and then listen for responses using NWListener on port 50913. Although the broadcast is sent out correctly (= no error is thrown upon sending), I only get responses to my broadcast from what I suppose are the network interfaces of my own MacBook. In other words, it seems like the broadcast is never really submitted to the network. Context I don't have in-depth knowledge about the behavior of UDP which is why I am confused about this behavior. I've been reading online about this and couldn't find anything really related to the behavior I am experiencing. I've also looked at this developer forums entry and implemented the broadcast accordingly. The response from @meaton does not suggest that broadcasts are not supported by NWConnection (which is what I thought to be the culprit initially), and I am not getting the error they are talking about in their post, but a behavior that is entirely different. Does anyone know what is wrong with my implementation? Code final public class BroadcastDiscoveryEngine { private let logger: Logger = Logger.init(for: BroadcastDiscoveryEngine.self) private let broadcastConnection: NWConnection private let broadcastResponseListener: NWListener private let responseParser: BroadcastResponseParser = BroadcastResponseParser() private var discoveryContinuation: AsyncStream<Discovery>.Continuation? = nil init() throws { let parameters = NWParameters.udp parameters.allowLocalEndpointReuse = true parameters.allowFastOpen = true parameters.includePeerToPeer = true broadcastConnection = NWConnection(host: .ipv4(.broadcast), port: .init(integerLiteral: 50913), using: parameters) broadcastResponseListener = try NWListener(using: parameters, on: 50913) } func startBroadcast(continuation: AsyncStream<Discovery>.Continuation) { discoveryContinuation = continuation broadcastConnection.stateUpdateHandler = handleBroadcastConnectionStateUpdate(state:) broadcastConnection.start(queue: .global(qos: .default)) startBroadcastListener() } func stopBroadcast() { broadcastConnection.cancel() broadcastResponseListener.cancel() } private func sendBroadcastMessage() { broadcastConnection.send(content: "my_broadcast_message".data(using: .utf8), completion: .contentProcessed({ error in if let error = error { self.logger.error("Sending broadcast message failed with error: \(error.debugDescription, privacy: .public)") self.broadcastConnection.cancel() self.broadcastResponseListener.cancel() } self.logger.info("Broadcast message sent.") })) } private func handleBroadcastConnectionStateUpdate(state: NWConnection.State) { switch state { // shortened other cases since only logging occurs case .ready: logger.info("Broadcast connection established, ready to send and receive data.") sendBroadcastMessage() } } } extension BroadcastDiscoveryEngine { private func startBroadcastListener() { broadcastResponseListener.stateUpdateHandler = handleBroadcastResponseListenerStateUpdate(state:) broadcastResponseListener.newConnectionHandler = handleIncomingConnection(connection:) broadcastResponseListener.start(queue: .global(qos: .default)) } private func handleBroadcastResponseListenerStateUpdate(state: NWListener.State) { switch state { // shortened cases since only logging occurs } } private func handleIncomingConnection(connection: NWConnection) { connection.stateUpdateHandler = { state in self.handleIncomingConnectionStateUpdate(connection: connection, state: state) } connection.start(queue: .global(qos: .default)) } private func handleIncomingConnectionStateUpdate(connection: NWConnection, state: NWConnection.State) { switch state { // shortened other cases since only logging occurs case .ready: logger.info("Incoming connection (\(connection.debugDescription, privacy: .public) established, ready to send and receive data.") connection.receiveMessage { content, contentContext, isComplete, error in self.receiveBroadcastResponse(connection: connection, content: content, contentContext: contentContext, isComplete: isComplete, error: error) } } } private func receiveBroadcastResponse(connection: NWConnection, content: Data?, contentContext: NWConnection.ContentContext?, isComplete: Bool, error: NWError?) { // shortened: handles parsing accordingly and then cancels connection connection.cancel() } }
2
0
432
Dec ’23
NetService can't resolve(withTimeout:) service connected via ethernet for iOS 17.1+ (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72007)
It worked fine before iOS 17.1. Just checked with iOS 16 on real device. And my teammate from QA department confirmed it works for iOS 17.0.1. The problem occurs only with device in local network connected via ethernet. The device itself has two options for connection - via Wi-Fi and Ethernet. It works for all iOS versions via Wi-Fi. But it can't resolve host for Ethernet connection. Error appears in func netService(_ sender: NetService, didNotResolve errorDict: [String : NSNumber]) looks like that: (NSNetServicesErrorDomain: 10, NSNetServicesErrorCode: -72007) Could you please explain this error code?
1
0
646
Dec ’23
Using NWConnectionGroup over UDP for implementing multicast group over multicast IP & given port range.
Our App design requires Apps to be able to discover and communicate with other Apps in the same Local/Enterprise network over a range of given ports. To facilitate this, I am exploring NWConnectionGroup over UDP. As per the following documentation (How to use multicast networking in your app) I am writing sample code where objective is to create a Multicast group among two different programs running on the same macOS (14.1) system and enabling multicast communication between them. Based on the following note in documentation I understand that I don’t need multicast entitlement if I am using sample code (Command Line Tool). Note: You can test your app using the iOS and iPadOS simulators without an active entitlement, but using multicast and broadcast networking on physical hardware requires the entitlement. Is this understanding correct? If yes. Approach 1: When I create multicast group in both the programs on same multicast IP and Port (224.0.0.251:8900), the second program is not executing and gives following "Address already in use" error. I have used allowLocalEndpointReuse (true) while creating NWConnectionGroup. Is this expected? Error Logs: Group entered state failed(POSIXErrorCode(rawValue: 48): Address already in use) Send complete with error Optional(POSIXErrorCode(rawValue: 89): Operation canceled) nw_path_evaluator_evaluate NECP_CLIENT_ACTION_ADD error 48 nw_path_create_evaluator_for_listener nw_path_evaluator_evaluate failed nw_listener_start_on_queue [L1] nw_path_create_evaluator_for_listener failed nw_connection_group_handle_listener_state_change [G1] listener failed with error nw_connection_group_send_message_internal [G1] Cannot send a message on a failed or cancelled group As per attached sample code, do you see anything specific which I might be missing, pointers to that will help. Note: Difference between Approach1 and Approach2 is only the Port Number Second Approach: So, I tried with same multicast IP but binding to different ports for both the programs (224.0.0.251:8900 & 224.0.0.251:8901). Here, for both the programs group.send() to self was getting received by the group.setReceiveHandler() but same multicast message was not being received by the other program. Question: Is this approach correct? If yes, what could be the reason behind NOT receiving the multicast messages? /************** NWConnectionGroup 1*********************/ import Foundation import Network // Create a NWMulticastGroup to describe the multicast group guard let multicast = try? NWMulticastGroup(for: [.hostPort(host: "224.0.0.250", port: 8900)]) else { fatalError("Error creating multicast group") } let params = NWParameters.udp; params.allowLocalEndpointReuse = true; // Create an NWConnectionGroup to handle multicast communication let group = NWConnectionGroup(with: multicast, using: params) // Set the handler for incoming messages group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in print("Received message from \(String(describing: message.remoteEndpoint))") if let content = content, let message = String(data: content, encoding: .utf8) { print("Received Message: \(message)")} //print("Current group members:", group.descriptor.members) for member in group.descriptor.members { switch member { case .hostPort(let host, let port): print("Member Host: \(host), Port: \(port)") default: print("Member Endpoint: \(member)") } } // Send acknowledgment //let sendContent = Data("ack from Device 1".utf8) /*group.send(content: sendContent) { (error) in print("Acknowledgment sent with error: \(String(describing: error))") }*/ if isComplete { print("Connection closed") } } // Set the state update handler group.stateUpdateHandler = { (newState) in print("Group entered state \(String(describing: newState))") } // Start the NWConnectionGroup group.start(queue: .main) // Send a message to the multicast group let groupSendContent = Data("Hello All from Device 1".utf8) group.send(content: groupSendContent) { (error) in print("Send complete with error \(String(describing: error))") } // Keep the run loop running RunLoop.main.run() /***************************NWConnectionGroup 2 **********************/ import Foundation import Network // Create a NWMulticastGroup to describe the multicast group guard let multicast = try? NWMulticastGroup(for: [.hostPort(host: "224.0.0.250", port: 8901)]) else { fatalError("Error creating multicast group") } let params = NWParameters.udp; params.allowLocalEndpointReuse = true; // Create an NWConnectionGroup to handle multicast communication let group = NWConnectionGroup(with: multicast, using: params) // Set the handler for incoming messages group.setReceiveHandler(maximumMessageSize: 16384, rejectOversizedMessages: true) { (message, content, isComplete) in print("Received message from \(String(describing: message.remoteEndpoint))") if let content = content, let message = String(data: content, encoding: .utf8) { print("Received Message: \(message)")} // Send acknowledgment /*let sendContent = Data("ACK from Device 2".utf8) group.send(content: sendContent, to: message.remoteEndpoint) { (error) in print("Acknowledgment sent with error: \(String(describing: error))") }*/ if isComplete { print("Connection closed") } } // Set the state update handler group.stateUpdateHandler = { (newState) in print("Group entered state \(String(describing: newState))") } // Start the NWConnectionGroup group.start(queue: .main) // Send a message to the multicast group let groupSendContent = Data("Hello All from Device 2".utf8) group.send(content: groupSendContent) { (error) in print("Send complete with error \(String(describing: error))") } // Keep the run loop running RunLoop.main.run()
2
0
578
Jan ’24
how to set an identity and get a certificate CN from a pkcs12 file
I am working on a Swift app which does a TLS connection to a server. I want to set an identity, which the server will validate. I'm given a pkcs12 file. The cert is not trusted locally on my system, but the server can validate it. First, I didn't need to import the cert - I just want to create an identity that I can use with my connection. I don't think that's possible, so I do this: var importStatus = SecPKCS12Import(pkcs12Data as CFData, importOptions as CFDictionary, &importArray) The first time I call this, it's successful. I have come to extract the identity (and certificate) from the importArray returned, but in my case, even though I get an errSecSuccess return status, the importArray is empty. So first question: why would it be empty? ( if the code is run again, I get an errSecDuplicateItem - I don't need to store it in the keychain but I guess I'm being forced to) When I imported, I used a UUID as my identifier - I set it in the options: let importOptions: [String: Any] = [ kSecImportExportPassphrase as String: password, kSecImportItemLabel as String: identifier ] So I try to retrieve the identity from the keychain: let identityQuery = [ kSecClass: kSecClassIdentity, kSecReturnRef: true, kSecAttrLabel: identifier ] as NSDictionary var identityItem: CFTypeRef? let status = SecItemCopyMatching(identityQuery as CFDictionary, &identityItem) where I pass the UUID as identifier, but I actually get back my apple identity, not the certificate. However, if I pass in the certificate's CN, (hard-coded for my testing) I get the right identity back. So my second question: am I doing something wrong? If i pass an ItemLabel on import, can I retrieve the certificate using that same label? So for me to get this working, I need to know the CN of my cert, or I need the ItemLabel to work so that I can just retrieve using a UUID. To determine the CN of my cert, the only apple API I found is this: SecCertificateCopyCommonName which requires the cert to be in .der format, rather than .pkcs12. So I have a bit of a chicken and egg problem. So my last question - is there a way to extract the CN from the pkcs12 file, or to convert the Data from .pkcs12 to .der? Thanks!
3
0
714
Dec ’23
802.1AS device priority
Hello, in avbutil --controller, when viewing stream settings on ATDECC in interface statistics under AVB interface: Thunderbolt Ethernet there are stream parameters as read-only values. How to change Priority 1 ant Priority 2 values? I assume there is some config file/terminal command that would modify these parameters. Using 13.6.2 (22G320)
0
0
223
Jan ’24
Inconsistency in FD creation of NWConnection on server side when compared within system (using localhost) and between systems.
During my exploration of NWConnection and NWListener I created sample code to implement communication between client and listener over UDP. To achieve that client and listener were created on the same machine using localhost. Same client and listener codes were also deployed on different macOS machines. Following are the observations: Observation1: Within the same macOS machine, Listener was created on a port X and from client side I used "localhost" and Port X to connect to the listener. To capture the behavior of the how the connections/FDs are getting created I used lsof & netstat commands and following were the output: LSOF: tw-macoffice-02-studio:~ nikhil.singh$ lsof -Pi :9001 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME NWListner 16775 nikhil.singh 4u IPv6 0x402b8381d3a12129 0t0 UDP *:9001 NWListner 16775 nikhil.singh 5u IPv6 0x402b8381d3a11129 0t0 UDP localhost:9001->localhost:64723 NWConnect 16785 nikhil.singh 4u IPv4 0x402b8381d3a10529 0t0 UDP localhost:64723->localhost:9001 Here, we can see that separate FDs are getting created for: NWListner - Listener FD - 4u and NWConnection (connection request) from listener to client FD - 5u on localhost with Process ID 16775 NWConnect - NWConnection from client to listener on localhost FD - 4u Process ID 16785 NETSTAT: tw-macoffice-02-studio:~ nikhil.singh$ netstat -an |grep 9001 udp4 0 0 127.0.0.1.9001 127.0.0.1.64723 udp4 0 0 127.0.0.1.64723 127.0.0.1.9001 udp46 0 0 *.9001 . Connection wise also we can see the two connections are listed. Observation 2: I used different macOS machines within the same network to implement listener and client side of the code. Here, the behavior in terms of socket FD creation on the listener side with incoming connection request was different. Listener Side: LSOF: nikhil.singh@Mac-Pro ~ % lsof -Pi :9001 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME UDP_Serve 31480 nikhil.singh 5u IPv6 0xb3b7cb5ed6d2edd7 0t0 UDP *:9001 NETSTAT: nikhil.singh@Mac-Pro ~ % netstat -an |grep 9001 udp46 0 0 *.9001 . udp4 0 0 10.20.16.144.9001 10.20.16.250.62758 Inconsistency: **For listener side, a new socket FD was not created when listener accepted the incoming connection. ** Client Side: LSOF tw-macoffice-02-studio:~ nikhil.singh$ lsof -Pi :9001 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME NWConnect 29015 nikhil.singh 4u IPv4 0x402b8381d3c74129 0t0 UDP 10.20.16.250:62758->tw-macoffice-01.tallysolutions.com:9001 NETSTAT tw-macoffice-02-studio:~ nikhil.singh$ netstat -an |grep 9001 udp4 0 0 10.20.16.250.62758 10.20.16.144.9001 For Client Side, a new FD was created from client to listener. Question: Why a new socket FD was not created on the Listener side when incoming connection was from a different machine over IP. Also, one Digression question: As a cross platform application, we plan to use Network Framework for Apple Kernel and BSD sockets for others. Similar to BSD, is there a way we can block a thread on connection.receiveMessage?
1
0
286
Jan ’24
How to set ATS preferences in Xcode 15 But no plist?
I want to allow network access in my app but I have an error nw_proxy_resolver_create_parsed_array [C1.1.1 proxy pac] Evaluation error: NSURLErrorDomain: -1003 which crashes my app although the seek command works and I get a correct value back from the internet server. I understood I could fix this as foilows? There is a section Info. Within Xcode 15 where you can find Custom macOS Application Target Properties. I selected App Transport Security Settings and the after pressing the drop down menu selected Allow Arbitrary Loads. Then to the left of that I press the menu and it shows YES and NO but if I try to select either of them neither appears in the key value box? Also I thought this would create a new Info.plist which I could then add my key values- but nothing happens.. I am very new to the so any help is much apprecated
2
0
494
Jun ’24
Inquiry about Address Ordering in CFHostGetAddressing Function
I have a query regarding the CFHostGetAddressing function that I'm using to retrieve addresses from a host. Specifically, I am curious about the predefined order of IPs in the array returned by this function when multiple IPs are present for a host. Here are my questions: In the case where both IPV6 and IPV4 addresses are present for a host, does the CFHostGetAddressing function return the addresses array with IPV6 at the 0th index and IPV4 following it? If a mapped IPv6 address is present along with an IPV4 address, does the function prioritize placing the mapped IPv6 address first in the addresses array, followed by the IPV4 address? I would appreciate it if someone could provide insights into any defined order for these scenarios. Additionally, if there is documentation or a reference page specifying this order, kindly point me in the right direction. Thank you in advance for your assistance.
2
0
293
Jan ’24
How IP_BOUND_IF works to bind a socket to a specific interface?
there is few document on explain how IP_BOUND_IF works. I use the following code to specific interface to sending my data , where on a device has both wifi and vpn. const char* device_name = "pdp_ip0"; int interfaceIndex = if_nametoindex(device_name); int res = setsockopt(socketfd, IPPROTO_IP, IP_BOUND_IF, &interfaceIndex, sizeof(interfaceIndex)); the res results 0 , but socket still send data via utun, witch is a vpn interface
1
0
348
Jan ’24
NWConnection, how to catch error?
I have a NWConnection, that if an invalid (ip/port), is entered, I get in debug the error: nw_socket_handle_socket_event [C1.1.1:1] Socket SO_ERROR 61. But I can't seem to trap that error. I have as my stateChangeHandler: I am creating my connection: let tcpOptions = NWProtocolTCP.Options() tcpOptions.enableKeepalive = true tcpOptions.keepaliveIdle = 2 tcpOptions.keepaliveCount = 2 tcpOptions.keepaliveInterval = 2 let params = NWParameters(tls: nil, tcp: tcpOptions) nwConnection:NWConnection(host: NWEndpoint.Host(host), port: NWEndpoint.Port(port)!, using: params). (with known nonexistent ip/port). I was hopping when I did a .start(), I would get an error in my state handler: // =============================================================================== func stateDidChange(to state: NWConnection.State) { Swift.print("State change") switch state { case .waiting(let error): print("Client waiting") connectionDidFail(error: error) case .ready: print("Client connection ready") case .failed(let error): print("Client failed") connectionDidFail(error: error) case .preparing: print("client preparing") case .setup: print("client setup") case .cancelled: print("client cancelled") default: print("Client unknown") break } } But it doesn't trap an error. So, where is this error coming from (I know the cause), but I want to trap it (in case a user puts in a wrong ip/port)
4
0
718
Jan ’24
Notification Service Extension usage time
Hello all. I noticed, that NSE living more than 30 seconds ( that described in doc ). When app receive notification, it created process NSE, and send notification to didReceive function, after this, app have 30 seconds to call contentHandler closure, after contentHandler is called, I expected that NSE process is killed, but it's not. If app using singletons in NSE, they won't dealloc after contentHandler is called, so, after new notification received, singletons still alive. Does it legal to not drop connection to websocket after contentHandler closure get called? For example, notification received, NSE process is loaded, websocket manager signleton is initialzied and started session, after few seconds contentHandler closure get called, so, system won't kill NSE because of 30 seconds timer, and my web socket connection will alive so long as possible, so, I not need to open it each 30 seconds, is that legal or not?)
3
0
529
Jan ’24
How to implement ping an IP in MacOS Swift?
Hi all, As far as my research, I found there are two ways to ping an IP Address (ipv4 and ipv6) in MacOS in Swift. SimplePing Run command line in code like below func doPing() { let task = Process() task.executableURL = URL(fileURLWithPath: "/sbin/ping") task.arguments = [ "-c", "4", "10.1.141.100" ] let outputPipe = Pipe() task.standardOutput = outputPipe let outputHandle = outputPipe.fileHandleForReading outputHandle.readabilityHandler = { pipe in if let ouput = String(data: pipe.availableData, encoding: .utf8) { if !ouput.isEmpty { log += ouput print("----> ouput: \(ouput)") } } else { print("Error decoding data: \(pipe.availableData)") } } task.launch() } So which way is better and which way should I implement for the project?
3
0
459
Jan ’24
Stealth Mode broken in Sleep
Hello here, There is a macOS feature called Stealth Mode under Firewall in System Settings. It's supposedly blocks ICMP request messages (aka Ping). It seems to work fine, only until the device is put to sleep. This can be done either manually from Apple Menu -> Sleep, or by simply closing the MacBook lid. The device suddenly starts replying to pings roughly 10 seconds after entering sleep mode. Exactly the same seems to happen even if I enable pf with a rule: block all Does anyone know what's happening? Seems like packet filtering or firewall is not applied anymore after the OS is put to sleep. Are the ICMP packets handled by the Kernel or WNIC firmware after sleep? I reported this through Apple Feedback Assistant but they were very dismissive and simply said they were not able to reproduce this.
0
0
278
Jan ’24