Re: [node] app.listen()問題
其實我覺得你可以先試著google或自己試,嘗試對寫程式是很重要。
我試著google: server.address() node,裡面有提到說他會回傳一個object。
他裡面又有說:
Don't call server.address()
until the 'listening' event has been emitted.
回去翻express-app.listen,他裡面寫到他是based on http.Server.listen()
再去翻node http server.listen,把兩種寫法都看完了以後
可以肯定要用的是server.listen(port[, hostname][, backlog][, callback])
進行嘗試
var server = app.listen(8081,'127.0.0.1',function(){
...
}
Example app listening at http://127.0.0.1:8081
隨便亂設IP他會報錯,代表他是吃自己這台IP。
總而言之,多嘗試很重要。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 118.163.30.31
※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1450401453.A.A60.html
推
12/18 10:13, , 1F
12/18 10:13, 1F
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章