 {EventEmitter} = require 'events'
 _ = require 'underscore-plus'
 
-socketPath = path.join(os.tmpdir(), 'atom.sock')
+socketPath =
+  if process.platform is 'win32'
+    '\\\\.\\pipe\\atom-sock'
+  else
+    path.join(os.tmpdir(), 'atom.sock')
 
 # Private: The application's singleton class.
 #

      app.quit() if process.platform is 'win32'

    app.on 'will-quit', =>
      fs.unlinkSync socketPath if fs.existsSync(socketPath) # Clean the socket file when quit normally.

    app.on 'open-file', (event, pathToOpen) =>
      event.preventDefault()

  # the other launches will just pass their information to this server and then
  # close immediately.
  listenForArgumentsFromNewProcess: ->
    if process.platform isnt 'win32' and fs.existsSync(socketPath)
      fs.unlinkSync socketPath
    server = net.createServer (connection) =>
      connection.on 'data', (data) =>
        @openWithOptions(JSON.parse(data))
