<div><br></div> <div>5장 5예제입니다.</div> <div>그대로 쳐서해도 이렇게 출력되는데 문제가 뭔가요??</div> <div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;">http_outgoing.js:457 </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;"> throw new TypeError('First argument must be a string or Buffer'); </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;"> ^ </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;">TypeError: First argument must be a string or Buffer </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;"> at ServerResponse.OutgoingMessage.write (_http_outgoing.js:457:11) </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;"> at ReadFileContext.callback (nodeexample1\ch05_test5.js:33:7) </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;"> at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:366:13) </div> <div class="console-element" style="padding-left:5px;color:#333333;line-height:18px;white-space:pre;font-family:'SourceCodePro-Medium', 'MS ゴシック', 'MS Gothic', monospace;background-color:#dfe2e2;">Program exited with code 1</div></div> <div>/**</div> <div> * 5장 Test 5</div> <div> * </div> <div> * http 모듈로 웹 서버 만들기</div> <div> * </div> <div> * 이미지 파일 읽어 응답으로 전송하기</div> <div> */</div> <div><br></div> <div>var http = require('http');</div> <div>var fs = require('fs');</div> <div><br></div> <div>// 웹서버 객체를 만듭니다.</div> <div>var server = http.createServer();</div> <div><br></div> <div>// 웹서버를 시작하여 3000번 포트에서 대기하도록 합니다.</div> <div>var port = 3001;</div> <div>server.listen(port, function() {</div> <div><span style="white-space:pre;"> </span>console.log('웹서버가 시작되었습니다. : %d', port);</div> <div>});</div> <div><br></div> <div>// 클라이언트 연결 이벤트 처리</div> <div>server.on('connection', function(socket) {</div> <div><span style="white-space:pre;"> </span>console.log('클라이언트가 접속했습니다. : %s, %d', socket.remoteAddress, socket.remotePort);</div> <div>});</div> <div><br></div> <div>// 클라이언트 요청 이벤트 처리</div> <div>server.on('request', function(req, res) {</div> <div><span style="white-space:pre;"> </span>console.log('클라이언트 요청이 들어왔습니다.');</div> <div><span style="white-space:pre;"> </span></div> <div><span style="white-space:pre;"> </span>var filename = '73.png';</div> <div><span style="white-space:pre;"> </span>fs.readFile(filename, function(err, data) {</div> <div><span style="white-space:pre;"> </span>res.writeHead(200, {"Content-Type": "image/png"});</div> <div><span style="white-space:pre;"> </span>res.write(data);</div> <div><span style="white-space:pre;"> </span>res.end();</div> <div><span style="white-space:pre;"> </span>});</div> <div><span style="white-space:pre;"> </span> </div> <div>});</div> <div><br></div> <div>// 서버 종료 이벤트 처리</div> <div>server.on('close', function() {</div> <div><span style="white-space:pre;"> </span>console.log('서버가 종료됩니다.');</div> <div>});</div> <div><br></div>
<div style="text-align:center;"><img src="http://eusave.dothome.co.kr/gif.php?id=0B9kuz3bbrNKXOG1iYnZIckZzMEU" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;"><img_ src="http://eusave.dothome.co.kr/gif.php?id=0B4MpkGgWbWt6T2lObjI2d293VW8" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;"><img_ src="http://eusave.dothome.co.kr/gif.php?id=0B1-Nk0QyKrjDeVlnM3hCYllaRkk" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;">
<div style="text-align:center;"><img_ src="http://eusave.dothome.co.kr/gif.php?id=0B1-Nk0QyKrjDeVlnM3hCYllaRkk" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;">
<div style="text-align:center;"><img_ src="http://eusave.dothome.co.kr/gif.php?id=0B1-Nk0QyKrjDRWlMa09ieDZsMlE" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;">
<div style="text-align:center;"><img_ src="http://eusave.dothome.co.kr/gif.php?id=0B8fuRvQ1iHqPX0lRN2drTXU5OWc" alt="iu.jpg" style="font-size:9pt;line-height:1.5;border:none;"></div>
<div style="text-align:center;"></div></div></div></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.