anchor.diff:            () => throw new TimeoutException(
                 'Postgresql connection timed out. $timeout', timeout);
         
  -      var future = settings.requireSsl
  -        ? _connectSsl(settings, timeout, onTimeout)
  -        : Socket.connect(settings.host, settings.port)
  -            .timeout(timeout, onTimeout: onTimeout);
  -
  -      return future.then((socket) {
  +      var connectFunc = mockSocketConnect == null
  +          ? Socket.connect
  +          : mockSocketConnect;
  +      
  +      Future<Socket> future = connectFunc(settings.host, settings.port)
  +        .timeout(timeout, onTimeout: onTimeout);
  +      
  +      if (settings.requireSsl) future = _connectSsl(future);
  +
  +      return future.timeout(timeout, onTimeout: onTimeout).then((socket) {
           var conn = new ConnectionImpl(socket, settings, typeConverter);
           socket.listen(conn._readData, 
               onError: conn._handleSocketError,
  
positive.code:   }
  
    //TODO yuck - this needs a rewrite.
    static Future<SecureSocket> _connectSsl(
        Settings settings, Duration timeout, onTimeout()) {
  
      var completer = new Completer<SecureSocket>();
  
      Socket.connect(settings.host, settings.port).then((socket) {
  
        socket.listen((data) {
          if (data == null || data[0] != _S) {
  
negative.code:       socket.add([0, 0, 0, 8, 4, 210, 22, 47]);
  
      })
      .catchError((e) {
        completer.completeError(e);
      });
  