Re: I need some feedback

2019-01-18 Thread Josh Graessley


> On Jan 18, 2019, at 3:18 PM, Jens Alfke  wrote:
> 
> 
> 
>> On Jan 18, 2019, at 1:04 PM, Quinn The Eskimo! > > wrote:
>> 
>> Implementing TLS for a peer-to-peer product like this one is not without its 
>> challenges,
> 
> It would be easy, if Apple provided a WebSocket API. I really, really wish 
> Apple would provide one. (And yes, I did file a Radar requesting it, six or 
> seven years ago.)

There is an implication here that a WebSocket API would support both a client 
and a server. Does your radar explicitly ask for client and server? Do you 
happen to have the radar number handy?

WebSockets will provide framing, which can make some things easier but it won’t 
help with TLS, especially when it comes to each side validating the identity of 
the peer.

Thanks,
-josh



smime.p7s
Description: S/MIME cryptographic signature
 ___
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Apple modern client/server paradigm

2018-08-03 Thread Josh Graessley


> On Aug 3, 2018, at 4:37 PM, Carl Hoefs  wrote:
> 
> I thought I should inquire before embarking on a major undertaking...
> 
> What is the "standardised" Apple paradigm for implementing modern 
> client/server between iOS "client" apps and a macOS "server"? (I'm updating a 
> low-level sockets paradigm...)
> 
> - Does one use Apache on macOS and place binaries into CGI-Executables? Or 
> use something like CocoaHTTPServer to create a custom server? Or...?
> 
> - On the iOS side, does one need only use NSURLConnection and friends? Or…?

If you’re using HTTPS use URLSession for the client. For the server I’m not 
certain the best approach.

If you’re rolling your own protocol or using a protocol other than HTTPS, you 
should consider Network.framework’s NWConnection or NSURLSessionStreamTask for 
the client and Network.frameworks NWListener for the server. For information on 
Network.framework, see WWDC session 715 
https://developer.apple.com/videos/play/wwdc2018/715/ 


-josh

 ___
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSNetServiceBrowser when a search finds nothing

2017-11-16 Thread Josh Graessley
The search is never finished until you decide it is by cancelling the browse.

Bonjour sends multicasts queries with an exponential backoff, up to some 
maximum amount of time. When a Bonjour service is advertised/registered on an 
interface, a multicast is sent out as well. As long as you have that browser 
open, Bonjour will keep watching for a matching service to appear, either as a 
response to one of the multicasts it sends or through an announcement sent by a 
device arriving on the networking or starting the service.

The only alternative is a timeout and timeouts are bad.

-josh

> On Nov 16, 2017, at 10:36 AM, James Walker  wrote:
> 
> If I use -[NSNetServiceBrowser searchForServicesOfType:inDomain:] and there 
> happen to be no services of the specified type, my delegate gets 
> netServiceBrowserWillSearch:, but nothing else.  How can I know when the 
> search is finished?
> ___
> Do not post admin requests to the list. They will be ignored.
> Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/macnetworkprog/jgraessley%40apple.com
> 
> This email sent to jgraess...@apple.com

 ___
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: __nw_connection_get_connected_socket_block_invoke 15 Connection has no connected handler

2017-05-08 Thread Josh Graessley


> On May 7, 2017, at 9:37 PM, Rick Mann  wrote:
> 
> Reposting on a better list…
> 
> Our app, which does a ton of network calls, gets a lot of console log 
> messages like:
> 
> __nw_connection_get_connected_socket_block_invoke 15 Connection has no 
> connected handler
> 
> Anyone know what this is? Google was not very helpful (people complain about 
> it, but I couldn't find any real answers).

nw_connection comes from libnetwork, a private low level networking library 
used by NSURLSession and CFNetwork. If you haven’t already done so, please file 
a radar. It sounds like someone is attempting to fetch the socket file 
descriptor for a connected that isn’t established.

-josh

 ___
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Can't get remote host and port after CFStreamCreatePairWithSocketToNetService

2015-04-13 Thread Josh Graessley

 On Apr 13, 2015, at 1:25 PM, Jens Alfke j...@mooseyard.com wrote:
 
 
 On Apr 13, 2015, at 10:12 AM, Jeff Johnson 
 publicpost...@lapcatsoftware.com wrote:
 
 I want the host and port is to send a Host header. I might be able to get 
 away without it, but I'd prefer to adhere to standards.
 
 I ended up having to implement this earlier today; here’s the code I came up 
 with. “_inputStream” is an NSInputStream opened on a TCP socket. Disclaimer: 
 I haven’t tested it much yet, and not at all with IPv6 addresses.
 
 - (NSString*) remoteHost {
 // First recover the socket handle from the stream:
 NSData* handleData = CFBridgingRelease(CFReadStreamCopyProperty(
   (__bridge 
 CFReadStreamRef)_inputStream,
   
 kCFStreamPropertySocketNativeHandle));
 if (!handleData || handleData.length != sizeof(CFSocketNativeHandle))
 return nil;
 CFSocketNativeHandle socketHandle = *(const 
 CFSocketNativeHandle*)handleData.bytes;
 // Get the remote/peer address in binary form:
 struct sockaddr_in addr;
 unsigned addrLen = sizeof(addr);
 if (getpeername(socketHandle, (struct sockaddr*)addr,addrLen)  0)
 return nil;
 // Format it in readable (e.g. dotted-quad) form, with the port number:
 char nameBuf[INET6_ADDRSTRLEN];
 if (inet_ntop(addr.sin_family, addr.sin_addr, nameBuf, 
 (socklen_t)sizeof(nameBuf)) == NULL)
 return nil;
 return [NSString stringWithFormat: @%s:%hu, nameBuf, 
 ntohs(addr.sin_port)];
 }

This seems sub-optimal as there can be many hostnames that resolve to a single 
address. A reverse-lookup of the address will yield one of those hostnames, but 
it might not be the one you’re looking for.

Also, what does this do if you connect through a proxy? The native handle could 
be a socket to a SOCKS (or other) proxy, right?

A radar requesting a better way to do this might be a good idea. If you file 
one, please forward me the radar #, thanks.

-josh


 ___
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list  (Macnetworkprog@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/macnetworkprog/archive%40mail-archive.com

This email sent to arch...@mail-archive.com