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

Network Documentation

Pinned Posts

Posts under Network tag

380 Posts
Sort by:
Post marked as Apple Recommended
19k Views
Hi,We are getting background crash in CFNetwork with tubemanager internal class. I have provided crashed thread and full log below. Could you please suggest solution to this crash.Thread 2 name:Thread 2 Crashed:0 CFNetwork 0x00000001825119e0 CFAllocatedReferenceCountedObject::_retainable_hash(void const*) + 0 (CFObject.cpp:204)1 CoreFoundation 0x0000000181d26fb8 CFBasicHashFindBucket + 164 (CFBasicHash.c:426)2 CoreFoundation 0x0000000181d26ec0 CFDictionaryGetValue + 160 (CFDictionary.c:416)3 CFNetwork 0x000000018253f3dc TubeManager::_onqueue_enqueueRequestForProtocol(MetaConnectionCacheClient*, HTTPRequestMessage const*, MetaConnectionOptions, BaseAwaitingTube*) + 80 (CFObject.h:712)4 CFNetwork 0x00000001825402f4 TubeManager::_onqueue_reenqueueAwaitingTube(BaseAwaitingTube*) + 112 (TubeManager.cpp:447)5 CFNetwork 0x0000000182540378 ___ZN11TubeManager21_onqueue_newTubeReadyEP4Tube13CFStreamError_block_invoke + 28 (TubeManager.cpp:662)6 libdispatch.dylib 0x0000000180cdd1c0 _dispatch_client_callout + 16 (object.m:455)7 libdispatch.dylib 0x0000000180ce8b24 _dispatch_block_invoke_direct + 376 (queue.c:2872)8 CFNetwork 0x000000018266ee98 RunloopBlockContext::_invoke_block(void const*, void*) + 36 (CoreSchedulingSet.mm:361)9 CoreFoundation 0x0000000181d2d9a8 CFArrayApplyFunction + 68 (CFArray.c:650)10 CFNetwork 0x000000018266ed7c RunloopBlockContext::perform() + 136 (CoreSchedulingSet.mm:315)11 CFNetwork 0x00000001826700a4 MultiplexerSource::perform() + 312 (CFNRunLoopMultiplexer.c:282)12 CFNetwork 0x000000018266fe10 MultiplexerSource::_perform(void*) + 64 (CFNRunLoopMultiplexer.c:47)13 CoreFoundation 0x0000000181e02278 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24 (CFRunLoop.c:1943)14 CoreFoundation 0x0000000181e01bc0 __CFRunLoopDoSources0 + 524 (CFRunLoop.c:1989)15 CoreFoundation 0x0000000181dff7c0 __CFRunLoopRun + 804 (CFRunLoop.c:2821)16 CoreFoundation 0x0000000181d2e048 CFRunLoopRunSpecific + 444 (CFRunLoop.c:3113)17 CFNetwork 0x000000018251bcec +[NSURLConnection(Loader) _resourceLoadLoop:] + 336 (NSURLConnection.mm:364)18 Foundation 0x000000018293a50c __NSThread__start__ + 1024 (NSThread.m:1163)19 libsystem_pthread.dylib 0x0000000180ee7860 _pthread_body + 240 (pthread.c:697)20 libsystem_pthread.dylib 0x0000000180ee7770 _pthread_start + 284 (pthread.c:744)21 libsystem_pthread.dylib 0x0000000180ee4dbc thread_start + 4https://mcafee.box.com/s/tdyjymvudfakt7k1nzszf7lpy9o6tr74
Posted Last updated
.
Post not yet marked as solved
0 Replies
3.8k Views
Transport Layer Security (TLS) is the most important security protocol on the Internet today. Most notably, TLS puts the S into HTTPS, adding security to the otherwise insecure HTTP protocol. IMPORTANT TLS is the successor to the Secure Sockets Layer (SSL) protocol. SSL is no longer considered secure and it’s now rarely used in practice, although many folks still say SSL when they mean TLS. TLS is a complex protocol. Much of that complexity is hidden from app developers but there are places where it’s important to understand specific details of the protocol in order to meet your requirements. This post explains the fundamentals of TLS, concentrating on the issues that most often confuse app developers. Note If you’re working on TLS in the local environment, for example, to talk to a Wi-Fi based accessory, see TLS For Accessory Developers. Server Certificates For standard TLS to work the server must have a digital identity, that is, the combination of a certificate and the private key matching the public key embedded in that certificate. TLS Crypto Magic™ ensures that: The client gets a copy of the server’s certificate. The client knows that the server holds the private key matching the public key in that certificate. In a typical TLS handshake the server passes the client a list of certificates, where item 0 is the server’s certificate (the leaf certificate), item N is (optionally) the certificate of the certificate authority that ultimately issued that certificate (the root certificate), and items 1…N-1 are any intermediate certificates required to build a cryptographic chain of trust from 0 to N. Note The cryptographic chain of trust is established by means of digital signatures. Certificate X in the chain is issued by certificate X+1. The owner of certificate X+1 uses their private key to digitally sign certificate X. The client can verify this signature using the public key embedded in certificate X+1. Eventually this chain terminates in a trusted anchor, that is, a certificate that the client trusts by default. Typically this anchor is a self-signed root certificate from a certificate authority. Note Item N is optional for reasons I’ll explain below. Also, the list of intermediate certificates may be empty (in the case where the root certificate directly issued the leaf certificate) but that’s uncommon for servers in the real world. Once the client gets the server’s certificate, it must evaluate trust on that certificate to confirm that it’s talking to the right server. There’s three levels of trust evaluation here: Basic X.509 trust evaluation checks that there’s a cryptographic chain of trust from the leaf through the intermediates to a trusted root certificate. The client has a set of trusted root certificates built in (these are from well-known certificate authorities, or CAs), and a site admin can add more via a configuration profile. This step also checks that none of the certificates have expired, and various other more technical criteria (like the Basic Constraints extension). Note This explains why the server does not have to include the root certificate in the list of certificates it passes to the client; the client has to have the root certificate installed if trust evaluation is to succeed. In addition, TLS trust evaluation (per RFC 2818) checks that the DNS name that you connected to matches the DNS name in the certificate. Specifically, the DNS name must be listed in the Subject Alternative Name extension. Note The Subject Alternative Name extension can also contain IP addresses, although that’s a much less well-trodden path. Also, historically it was common to accept DNS names in the Common Name element of the Subject but that is no longer the case on Apple platforms. App Transport Security (ATS) adds its own security checks. Basic X.509 and TLS trust evaluation are done for all TLS connections. ATS is only done on TLS connections made by URLSession and things layered on top URLSession (like WKWebView). In many situations you can override trust evaluation; for details, see Technote 2232 HTTPS Server Trust Evaluation). Such overrides can either tighten or loosen security. For example: You might tighten security by checking that the server certificate was issued by a specific CA. That way, if someone manages to convince a poorly-managed CA to issue them a certificate for your server, you can detect that and fail. You might loosen security by adding your own CA’s root certificate as a trusted anchor. IMPORTANT If you rely on loosened security you have to disable ATS. If you leave ATS enabled, it will require that default server trust evaluation succeed regardless of any customisations you do. Client Certificates The previous section discusses server trust evaluation, which is required for all standard TLS connections. That process describes how the client decides whether to trust the server. Client certificate authentication, sometimes known as mutual TLS, is the opposite of that, that is, it’s the process by which the server decides whether to trust the client. Client certificate authentication is optional. The server must request a certificate from the client and the client may choose to supply one or not (although if the server requests a certificate and the client does not supply one it’s likely that the server will then fail the connection). At the TLS protocol level this works much like it does with the server certificate. For the client to provide this certificate it must apply a digital identity to the connection, and TLS Crypto Magic™ assures the server that, if it gets a certificate from the client, the client holds the private key associated with that certificate. Where things diverge is in trust evaluation. Trust evaluation of the client certificate is done on the server, and the server uses its own rules to decided whether to trust a specific client certificate. For example: Some servers do basic X.509 trust evaluation and then check that the chain of trust leads to one specific root certificate; that is, a client is trusted if it holds a digital identity whose certificate was issued by a specific CA. Some servers just check the certificate against a list of known trusted client certificates. When the client sends its certificate to the server it actually sends a list of certificates, much as I’ve described above for the server’s certificates. In many cases the client only needs to send item 0, that is, its leaf certificate. That’s because: The server already has the intermediate certificates required to build a chain of trust from that leaf to its root. There’s no point sending the root, as I discussed above in the context of the server trust evaluation. However, there are no hard and fast rules here; the server does its client trust evaluation using its own internal logic, and it’s possible that this logic might require the client to present intermediates, or indeed present the root certificate even though it’s typically redundant. If you have problems with this, you’ll have to ask the folks running the server to explain these requirements. Note If you need to send additional certificates to the server, you can do this by passing them to the certificates parameter of the method you use to create your URLCredential (typically init(identity:certificates:persistence:)). One thing that bears repeating is that trust evaluation of the client certificate is done on the server, not the client. The client does not care whether the client certificate is trusted or not. Rather, it simply passes that certificate the server and it’s up to the server to make that decision. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Updates: 11 Nov 2016 — First posted. 29 Oct 2018 — Minor editorial updates. 17 Apr 2020 — Updated the discussion of Subject Alternative Name to account for changes in the 2019 OS releases. Minor editorial updates. 26 Feb 2021 — Fixed the formatting. Clarified that ATS only applies to URLSession. Minor editorial changes. 3 Jun 2022 — Added a link to TLS For Accessory Developers.
Posted
by eskimo.
Last updated
.
Post not yet marked as solved
1 Replies
172 Views
According to Section 2.6.2 of RFC 3927, 169.254.255.255 is the broadcast address for the Link-Local prefix. This does not seem to work in macOS; what I see in WireShark are ARP messages "Who has 169.254.255.255?". Which obviously doesn't work. I'm on macOS 12.4 / Xcode 13.4. Same code works fine in Linux (Ubuntu 20.04). Anybody have any ideas?
Posted
by pkeller.
Last updated
.
Post not yet marked as solved
2 Replies
194 Views
I want my app to react when it sees that a certain port is being listened to, and likewise when it stops being listened to. Specifically, another app will start a gdb server (at 127.0.0.1 on 9003) and I want mine to detect that. I don't really even care that it's a gdb server, just when the port is in use or not. I can do it right now using polling using a variation of this but that's not great for CPU wakes. I'm wondering if I can use an NWConnection (with no timeout) to monitor for these events (port in use, port no longer in use). If so, any pointers would be very gratefully received :) Even if just to say I'm barking up the wrong tree!
Posted
by Haggis.
Last updated
.
Post marked as solved
1 Replies
200 Views
I have a data that should be transmitted using UDP with NWConnection. Size of data is larger than maximum datagram size provided by UDP, so I need to split data to send it. I tried to find solution with searching about UDP data split, but couldn't find appropriate solution to my problem. Which keyword should I search about to start from?
Posted
by EricKwon.
Last updated
.
Post not yet marked as solved
4 Replies
307 Views
Hi Quinn, I am developing an app that connects to a local device via Wifi or Ethernet. I am using tcp over Network.framework for the communication. My network connector is configured as such for iOS: let tcp_params = NWParameters.tcp         tcp_params.preferNoProxies = true         tcp_params.acceptLocalOnly = true         tcp_params.prohibitedInterfaceTypes = [.cellular] So what happens is that everything is fine as long as both the iPhone and the device are connected to an AccesPoint. But there is another option where the device acts as AccessPoint and you can join that network straight. The device, since it has no connection to the internet, does not offer a default route - so that any client devices can still use cellular network to access the internet. What happens though is that I cannot get a connection to that device in case cellular data is on. The state handler shows the following error message: lC3 MINI-20001._cap._tcp.local. tcp, no cellular, prefer no proxy, attribution: developer, path unsatisfied (Denied over cellular interface), interface: pdp_ip0[lte], ipv4, ipv6, expensive] As soon as I disable cellular data, everything works fine. Is there any way to get around this? There must be cause Safari can actually connect to the device even with cellular data on. I have played with various ways to configure the NWParameters, but no luck. Maybe you got the magic? Cheers, Michael
Posted Last updated
.
Post not yet marked as solved
3 Replies
384 Views
I have a wireless stateless-switch within my private network (LAN) which transmits HTTP posts to a configured URL (e.g. an always-on MacMini) about the switch's state. Upon receipt of a post, my MacOS app will then take appropriate action. No response to the sender is required. The frequency of posts will be minimal ( a few per day), but require immediate attention when received. The LAN is protected from external misuse by a secure gateway. I'd appreciate any suggestions for a lightweight solution (i.e. not a full-blown web-server), either as an overview of methods or sample source (e.g. on GitHub). Regards, Michaela
Posted Last updated
.
Post marked as solved
3 Replies
318 Views
This thread rvictl not working on big sur and … | Apple Developer Forums was locked with very optimistic: "There have been significant improvements to RVI in recent releases" No idea how because I simply cannot get it working: After enabling kernel extension in Recovery and Allow in Security (with two reboots), SIP back ON (but also tried off) I cannot get anything from rvictl Xcode 13.4 Build version 13F17a manager@localmagersMini ~ % which -a rvictl /Library/Apple/usr/bin/rvictl manager@localmagersMini ~ % /Library/Apple/usr/libexec/rpmuxd rpmuxd_transaction_begin:109 Transactions moved from 0->1 rpmuxd_transaction_end:121 Transactions moved from 1->0, starting idle timer rpmuxd_transaction_end_block_invoke_2:132 Idle timer fired, exiting. manager@localmagersMini ~ % sudo launchctl list com.apple.rpmux Could not find service "com.apple.rpmux" in domain for system manager@localmagersMini ~ % sudo launchctl load -w /Library/Apple/System/Library/LaunchDaemons/com.apple.rpmuxd.plist /Library/Apple/System/Library/LaunchDaemons/com.apple.rpmuxd.plist: service already loaded Load failed: 37: Operation already in progress manager@localmagersMini ~ % sudo kextload /Library/Apple/System/Library/Extensions/RemoteVirtualInterface.kext Executing: /usr/bin/kmutil load -p /Library/Apple/System/Library/Extensions/RemoteVirtualInterface.kext Error Domain=KMErrorDomain Code=71 "Kernel request failed: (libkern/kext) kext (kmod) start/stop routine failed (-603946985)" UserInfo={NSLocalizedDescription=Kernel request failed: (libkern/kext) kext (kmod) start/stop routine failed (-603946985)} manager@localmagersMini ~ % rvictl -s 00008101-000979680a04001e manager@localmagersMini ~ % ifconfig -l lo0 gif0 stf0 XHC0 XHC1 anpi1 anpi0 XHC2 en0 en4 en5 en2 en3 en6 en7 ap1 en1 bridge0 awdl0 llw0 utun0 utun1 utun2 manager@localmagersMini ~ % rvictl -l Could not get list of devices Anybody has any ideas? sebus
Posted
by sebus.
Last updated
.
Post not yet marked as solved
2 Replies
229 Views
A number of years ago I wrote code that uses dns_open(...) and dns_lookup(...) to call a remote name server for dns resolution. Testing in Monterey, Big Sur and Catalina I get a NULL reply from dns_lookup. The code produces an expected result with Mojave and High Sierra. If I pass NULL as the argument to dns_open() then resolution is successful, but that is not using the desired name server. I have submitted feedback request FB10027085 with a small project that demonstrates the failure.
Posted
by granada29.
Last updated
.
Post marked as solved
5 Replies
454 Views
The man page of "connect" states (snippet below): ".... datagram sockets may use connect() multiple times to change their association. Datagram sockets may dissolve the association by calling disconnectx(2), or by connecting to an invalid address, such as a null address ..." Up until 12.3.1 (and even 12.4 Beta1), if a connect() call was used on a datagram socket to disconnect an IPv4-mapped IPv6 address, the call used to complete and return back "EADDRNOTAVAIL". Internally it would indeed dissolve the current association of the connected datagram socket (i.e. subsequent calls to "send" would return back a "EDESTADDRREQ" errno). However, starting 12.4 Beta2, if a connect() call is made on such a datagram socket which is connected to a IPv4-mapped IPv6 address, the call now returns a "EINVAL" errno. Do note that this change in behaviour is happening in this Beta release only with IPv4-mapped IPv6 addresses. Other addresses like plain IPv6 address, continue to return "EADDRNOTAVAIL" on such connect() calls which are used to dissolve the current association. We have been able to reproduce this issue with a trivial C program that is attached to this discussion. The attached program, creates a datagram socket which then connects to a IPv4-mapped IPv6 loopback address. This connect is expected to succeed and does succeed. Once the connect is done, a next connect() is issued on the connected datagram socket, this time passing it a null address (as noted in the man page) and this call is expected to dissolve the connection association. The program expects a EADDRNOTAVAIL to be returned by this call (since that's what was being returned in all MacOS releases so far) and if some other errno gets returned then the program fails. When the attached reproducer is run against 12.3.1 (or other previous MacOS versions or even 12.4 Beta1), the program gets the expected EADDRNOTAVAIL and when it is run against 12.4 Beta2, it gets the unexpected EINVAL errno. Here's a sample output from 12.3.1 (the "successful" one): $> sw_vers ProductName: macOS ProductVersion: 12.3.1 BuildVersion: 21E258 $> clang main.c $> ./a.out created a socket, descriptor=3 trying to bind to addr ::ffff:127.0.0.1:0, addr family=30 Bound socket to ::ffff:127.0.0.1:46787, addr family=30 created another socket, descriptor=4 connecting to ::ffff:127.0.0.1:46787, addr family=30 successfully connected Disconnecting using addr :::0, addr family=30 got errno 49, which is considered OK for a connect to null address (a.k.a disconnect) Successfully disconnected Output from 12.4 Beta2 (the case where the behaviour has changed): $> sw_vers ProductName: macOS ProductVersion: 12.4 BuildVersion: 21F5058e $> clang main.c $> ./a.out created a socket, descriptor=3 trying to bind to addr ::ffff:127.0.0.1:0, addr family=30 Bound socket to ::ffff:127.0.0.1:23015, addr family=30 created another socket, descriptor=4 connecting to ::ffff:127.0.0.1:23015, addr family=30 successfully connected Disconnecting using addr :::0, addr family=30 Got unexpected errno 22 disconnect failed: Invalid argument Notice how the call to connect() to dissolve the connected association now returns errno 22 == Invalid Argument. We had a look at the release notes here https://developer.apple.com/documentation/macos-release-notes/macos-12_4-release-notes but they appear to be very high level release notes and we couldn't find anything relevant related to this change. So: Is this an intentional change? Are applications expected to account for this errno to be returned when calling connect() to dissolve a connected association of a datagram socket? If this is intentional, is there a reason why this is specific only for IPv4-mapped IPv6 address? The man connect page also talks about using disconnectx as an alternative way to dissolve the association. This appears to be specific to MacOS systems (couldn't find it in BSD man pages for example). Is disconnectx the recommended way to do the dissociation? P.S: I created a issue for this through the bug/feedback reporting tool (issue id: FB9996296), but there hasn't been any response to it since almost a week. So creating this thread in the forums hoping to get some inputs. main.c
Posted
by jaikiran.
Last updated
.
Post not yet marked as solved
4 Replies
347 Views
Hello, I'm working on an Apple Watch/ iPhone/PC/Mac OS sport applications with different types of connectivity and i'm a bit stuck with the bellow issue. I'm trying to Resolve a Bonjour that is using NWBrowser on WatchOS 8.6 on Apple Watch SE with LTE and i encounter strange issues: First i'm setup a NWBrowser : NWBrowser(for: .bonjourWithTXTRecord(type: "_angry._tcp", domain: nil), using: parameters) Then, using : browser?.browseResultsChangedHandler = { [weak self] results, changes in Everything works well until here I'm gathering info form name and txt of the service found and ask the client if i want's a connection to service found . Using NWConnection to connecting to the found enpoint: NWConnection(to: endpoint, using: params) Here starts the issue In the stateUpdateHandler : connection?.stateUpdateHandler = { state in     switch state {     case .ready:      if let innerEndpoint = connection?.currentPath?.remoteEndpoint,        case .hostPort(let host, let port) = innerEndpoint { i'm checking the port and host where i'm getting the wrong informations, an IPV6 and a port that don't exists on the target server and a log in the console : 2022-05-22 15:54:33.146148+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_copy_synthesized_url Endpoint type is not an address or host, cannot synthesize URL 2022-05-22 15:54:33.319537+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.319604+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.319621+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.319636+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.319651+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.501821+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.501875+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.501892+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.501908+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching 2022-05-22 15:54:33.501923+0300 WatchKit Extension[956:609596] [] nw_endpoint_proxy_match_exception_to_endpoint Invalid proxy endpoint type 3 for matching I tried this on an apple watch simulator and a couple of real iPhone devices and everything works well, i'm getting the good port and host and no console errors/warnings. PS: All this are done during a running HKWorkoutSession to ensure that the app is kept active during different networking operations. What i'm doing wrong since is working fine on iPhone and WatchOS Simulator? Thanks , Angry Software
Posted
by AngryS.
Last updated
.
Post not yet marked as solved
0 Replies
139 Views
Hi, I'm trying to send audio data via UDP. I am using Network.framework with networking, so to use send method in NWConnection sending data must be Data type or confirm to DataProtocol. To satisfy those conditions, I have implemented a method to convert from AVAudioPCMBuffer type to Data type. func makeDataFromPCMBuffer(buffer: AVAudioPCMBuffer, time: AVAudioTime) -> Data {         let audioBuffer = buffer.audioBufferList.pointee.mBuffers         let data: Data!         data = .init(bytes: audioBuffer.mData!, count: Int(audioBuffer.mDataByteSize))         return data     } Implementation above is referenced from this post The problem is that the size of converted data is too big to fit in UDP datagram and error below occurs when I try to send data. I have found out that initial size of buffer is too big to fit in maximumDatagramSize. Below is code regarding to buffer.         let tapNode: AVAudioNode = mixerNode         let format = tapNode.outputFormat(forBus: 0)         tapNode.installTap(onBus: 0, bufferSize: 4096, format: format, block: { (buffer, time) in          // size of buffer: AVAudioPCMBuffer is 19200 already.             let bufferData = self.makeDataFromPCMBuffer(buffer: buffer, time: time)             sharedConnection?.sendRecordedBuffer(buffer: bufferData)         }) I need to reduce size of AVAudioPCMBuffer to fit in UDP datagram, But I can't find right way to do it. What would be best way to make data fit in datagram? I thought of dividing data in half, but this is UDP so I'm not sure how to handle those datas when one data has lost. So I'm trying to make AVAudioPCMBuffer fit in datagram. Any help would be very appreciated!
Posted
by EricKwon.
Last updated
.
Post marked as solved
2 Replies
195 Views
I am trying to send and receive an audio data(saved by .caf extension device) using Network.framework. This is my plan. convert file into Data type using below code: guard let data = try? Data(contentsOf: recordedDocumentURL) else {             print("recorded file to data conversion failed in touchUpCallButton Method")             return         } send Data type data using NWConnection.send, UDP. receive Data type data using NWConnection.receiveMessage convert received Data type data into AVAudioFile type data and play it using AVAudioEngine Right now my problem is that size of data converted from audio file is too big to fit in maximumDatagramSize to send. So in my understanding, I need to split Data type into many small bytes of data and send it one by one. But in this case, I need to collect received data to make complete audio file again, so received device can play complete audio file. And.. I'm stuck at this step. I can't find right solution to divide Data type into small pieces to send by datagram using UDP. What I have in my mind is to use 'subdata(in: Range<Data.Index>) -> Data' function and 'append(Data)' function to divide and sum up data. Is this right approach to solve my problem? Little advice would be very appreciated!
Posted
by EricKwon.
Last updated
.
Post not yet marked as solved
6 Replies
1.6k Views
I am trying to connect wpa2 enterprise wifi using iPhone app programmatically.before that I tried connecting to that wifi manually:From Settings in iPhone deviceUsed these three parameters SSID, Username, passwordAfter that it ask to trust the certificate and trusting the certificate, the wifi get connect, Done!Now I am trying to connect wifi programmatically using following code:NEHotspotEAPSettings *settings = [[NEHotspotEAPSettings alloc]init]; settings.password = self.password.text; settings.username = self.username.text; settings.supportedEAPTypes = [NSArray arrayWithObjects:[NSNumber numberWithInteger:NEHotspotConfigurationEAPTypeEAPPEAP], nil]; NEHotspotConfiguration *configuration = [[NEHotspotConfiguration alloc]initWithSSID:self.ssid.text eapSettings:settings]; [[NEHotspotConfigurationManager sharedManager]applyConfiguration:configuration completionHandler:^(NSError * _Nullable error) { if (error) { NSLog(@"Error: %@",error.localizedDescription); } else { NSLog(@“Connected”); } }];but this code gives an errorInvalid EAP settings : NEHotspotConfiguration EAP settings must have either trusted server certificates or trusted server names configuredSince I don’t have any trusted server certificate or trusted server name. What should I set in the **** property of NEHotspotEAPSettings (passing nil also gives me same error)settings.trustedServerNamesPlease help to solve this. Thanks!
Posted Last updated
.
Post marked as solved
1 Replies
206 Views
I have a downchannel half-connection to the Amazon Alexa cloud https://developer.amazon.com/en-US/docs/alexa/alexa-voice-service/manage-http2-connection.html#create Now, if the APP enters the background, my connection will be broken. Even if I put it in the backgroundTask, I cannot maintain the connection through ping, How do I maintain this HTTP persistent connection when the APP is in the background, plz。
Posted
by tongxingx.
Last updated
.
Post marked as Apple Recommended
159 Views
I want to create an app that only scans the nearby wifi network and checks whether the user's wifi network is present in the scanned list or not. NO connection requires. How to achieve it. I tried almost all the options. I am getting the current connected WIFI SSID and BSSID with help of CaptiveNetwork.
Posted Last updated
.
Post marked as solved
3 Replies
380 Views
We have both an iOS app and a tvOS app. We'd love to achieve the following scenario: iOS app should be able to detect Apple TV devices in the local network. When the user selects the apple TV device, check if the our tvOS app on apple TV is installed or not on the selected apple tv, If the app is not installed then iOS app can open the app store to launch the install page for the tvOS app on apple tv. The user can download/installation the app of the tvOS app. If the tvOS app is installed then launch the tvOS App on the apple TV. Are there any APIs available to achieve this scenario?
Posted
by nandishyb.
Last updated
.
Post marked as solved
1 Replies
159 Views
Hi, I'm trying to build a Walki-talkie app using Swift. My Idea is... record user's voice by AVAudioEngine in device1 convert recorded file into Data type data send data from device1 to device2 using NWConnection.send receive data using NWConnection.receiveMessage play received data in device2 I am implementing this app using P2P option in Network.framework, so each device has both browser and listener. And I have to make each device to keep receiving incoming data, and to send recorded voices. At first I thought that if receiveMessage method was executed, it would wait for other device's send method to send data and receive it. But while debugging, program didn't stopped at receiveMessage method, it just went through and executed next line. I must be missing something, but I'm not sure what it is. Below is send and receive part of code I tried.     func sendRecordedAudio(data: Data) {         guard let connection = connection else {             print("connection optional unwrap failed: sendRecordedAudio")             return         }         connection.send(content: data, completion: .contentProcessed({ (error) in             if let error = error {                 print("Send error: \(error)")             }         }))     }     func receiveRecordedAudio() {                 guard let connection = connection else {             print("connection optional unwrap failed: receiveRecordedAudio")             return         }         connection.receiveMessage{ (data, context, isComplete, error) in             if let error = error {                 print("\(error) occurred in receiveRecordedAudio")             }             if let data = data {                 self.delegate?.receivedAudio(data: data)             }         }     } App is calling sendRecordAudio when recording audio is ended, and calling receiveRecordeAudio when user pressed receive button. Any help would be greatly appreciated!
Posted
by EricKwon.
Last updated
.
Post not yet marked as solved
1 Replies
143 Views
Consider the following situation: user uploads a large file via a share extension (extension writes upload details into shared DB and initiates background transfer), then quickly realizes that's a wrong file, so he switches to containing app, opens up a list of uploads and hits "Cancel". Question is, how containing app is supposed to reliably cancel such transfer, given that only one process can access same NSURLSession at the time, a session is not disconnected until all tasks are complete (or connected process is terminated) and extension may not be terminated yet?
Posted Last updated
.