     net = require "net"
     buffer = ''
     try
-      @close()
-      @GlobalContext?.notifyConsoleMessage "Listening on Address:Port " + @serverAddress + ":" + @serverPort
-      console.log "Listening on Address:Port " + @serverAddress + ":" + @serverPort
+      console.log "Attempting to setup server"
+      if @listening()
+        @close()
       @server = net.createServer( (socket) =>
-
         socket.setEncoding('ascii');
         if !@GlobalContext.getCurrentDebugContext()
           @GlobalContext?.notifyConsoleMessage "Session initiated"

    @serverAddress = params.serverAddress

  setPort: (port) ->
    @serverPort = port
    if @listening
      @close()
      @listen()


  setAddress: (address) ->
    @serverAddress = address
    if @listening
      @close()
      @listen()

  setAddressPort: (address,port) ->
    @serverPort = port
    @serverAddress = address
    if @listening
      @close()
      @listen()

  listening: ->
    return @server != undefined

        @close()
        @GlobalContext.notifySocketError()
        return false
      serverOptions = {}
      serverOptions.port = @serverPort
      if @serverAddress != "*"
        serverOptions.host = @serverAddress

      @server?.listen serverOptions, () =>
          @GlobalContext?.notifyConsoleMessage "Listening on Address:Port " + @serverAddress + ":" + @serverPort
          console.log "Listening on Address:Port " + @serverAddress + ":" + @serverPort
      return true
    catch e
      @GlobalContext?.notifyConsoleMessage "Error: " + "Socket Error:", e
