作者y2468101216 (芸)
看板Ajax
標題Re: [node] app.listen()問題
時間Fri Dec 18 09:17:30 2015
其實我覺得你可以先試著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://webptt.com/m.aspx?n=bbs/Ajax/M.1450401453.A.A60.html
1F:推 luckid: 感謝前輩指點,小的學習態度確實不夠積極,一定改進 12/18 10:13