     # Start with node creators
     nodes "Node"
 
-  connectPort: (socket, process, port, index, inbound) ->
+  connectPort: (socket, process, port, index, inbound, callback) ->
     if inbound
       socket.to =
         process: process

        index: index

      unless process.component.inPorts and process.component.inPorts[port]
        throw new Error "No inport '#{port}' defined in process #{process.id} (#{socket.getId()})"
        return
      if process.component.inPorts[port].isAddressable()
        return process.component.inPorts[port].attach socket, index
      return process.component.inPorts[port].attach socket

    socket.from =
      process: process

    # Subscribe to events from the socket
    @subscribeSocket socket, from

    @connectPort socket, to, edge.to.port, edge.to.index, true, (err) =>
      return callback err if err
      @connectPort socket, from, edge.from.port, edge.from.index, false, (err) =>
        return callback err if err

        @connections.push socket
        callback()

  removeEdge: (edge, callback) ->
    for connection in @connections
