 
 # reads the options' `plugins` value and loads them into a chain
 buildPluginChain = require './plugin-chain'
+
+# help out client connect listeners by supplying `socket` as first arg.
+# return a function which passes `this` as the first arg cuz its the socket
+addSocketArg = (fn) -> -> fn this
+
+onConnectWrapper = (event, listener) ->
+  if event is 'connect' then listener = addSocketArg listener
+  this.originalOn event, listener
+
+onceConnectWrapper = (event, listener) ->
+  if event is 'connect' then listener = addSocketArg listener
+  this.originalOn event, listener
 
 module.exports = (builderOptions) ->
 

        maxRetries: options.maxRetries
        relisten  : options.relisten

    # 5. all done
    return socket

  # our module's API is the two creation functions and an "add a plugin" function

    if options.onConnect?
      socket.on (if isServer then 'connection' else 'connect'), options.onConnect

    # 5. add 'relistener'
    # I'm choosing to keep the `relistener` ability in `cio` and adding it
    # unless specified *not* to. It's a simple helper for an annoying issue.
    if isServer and options.relistener isnt false
