<p style="margin:0px 0px 6px;color:#141823;font-family:helvetica, arial, 'lucida grande', sans-serif;font-size:14px;line-height:19.3199996948242px;">tcp/ip 소켓프로그래밍에 관하여 도움 부탁드립니다.</p> <p style="margin:6px 0px;color:#141823;font-family:helvetica, arial, 'lucida grande', sans-serif;font-size:14px;line-height:19.3199996948242px;">ftp 클라이언트와 서버를 만들고 있는 와중에 클라이언트의 ls 요청에 서버가 현재 디렉토리 목록을 클라이언트에게 보내는 부분에서 계속해서 오류가 발생합니다.</p> <p style="margin:6px 0px;color:#141823;font-family:helvetica, arial, 'lucida grande', sans-serif;font-size:14px;line-height:19.3199996948242px;">클라이언트의 해당 함수 소스 입니다.<span class="text_exposed_show" style="display:inline;"><br>void FileListShow(int sock)<br>{<br>uint8_t msgType = FileList;<br>ssize_t numBytesSent = send(sock, &msgType, sizeof(msgType), 0);<br>if (numBytesSent == -1) {<br>printf("send() error");<br>exit(1);<br>}<br>else if (numBytesSent != sizeof(msgType)) {<br>printf("sent unexpected number of bytes");<br>exit(1);<br>}</span></p> <div class="text_exposed_show" style="display:inline;color:#141823;font-family:helvetica, arial, 'lucida grande', sans-serif;font-size:14px;line-height:19.3199996948242px;"> <p style="margin:0px 0px 6px;">int n, len;<br>char *temp;<br>int length = 0;</p> <p style="margin:6px 0px;">char rcvBuffer[BUFSIZE];</p> <p style="margin:6px 0px;">temp = rcvBuffer;<br>while ((n = read(sock, temp, 1)) > 0)<br>{</p> <p style="margin:6px 0px;">if (length == BUFSIZE)<br>break;<br>temp++;<br>length++;</p> <p style="margin:6px 0px;">}</p> <p style="margin:6px 0px;">rcvBuffer[length] = '\0';</p> <p style="margin:6px 0px;">printf("received Data : %s\n", rcvBuffer);</p> <p style="margin:6px 0px;">close(sock);</p> <p style="margin:6px 0px;">}</p> <p style="margin:6px 0px;">서버의 해당 함수 소스 코드입니다.</p> <p style="margin:6px 0px;">void FileListShow(int clnt_sock)<br>{</p> <p style="margin:6px 0px;">DIR *dp;<br>struct dirent *dir;</p> <p style="margin:6px 0px;">dp = opendir( ".");<br>if (NULL != dp) <br>{<br>while (dir = readdir(dp))<br>{<br>if (dir->d_ino == 0)<br>{<br>break;<br>}</p> <p style="margin:6px 0px;">send(clnt_sock, dir->d_name, strlen(dir->d_name), 0);<br>send(clnt_sock, " ", 1, 0);</p> <p style="margin:6px 0px;">}<br>}<br>closedir(dp);</p> <p style="margin:6px 0px;"><br>}</p> <p style="margin:6px 0px;">함수의 매개변수는 각 각 파일 디스크립터입니다. <br>실행하여 클라이언트에서 ls 를 입력시 서버, 클라이언트 둘다 반응이 없다가 서버를 강제 종료시키면 그제서야 클라이언트에서 파일 목록이 나타납니다. 어느 부분때문에 무한루프? 같은것에 빠지는것 같은데 그 원인을 모르겠습니다</p> <p style="margin:6px 0px;"></p> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/201505/1432198557yQv3T5Jlvo.jpg" width="729" height="626" alt="캡처.JPG" style="border:none;"></div> <div style="text-align:left;"><img src="http://thimg.todayhumor.co.kr/upfile/201505/1432198557yw4n4H7Y.jpg" width="734" height="638" alt="캡처1.JPG" style="border:none;"></div><br><p></p></div>
댓글 분란 또는 분쟁 때문에 전체 댓글이 블라인드 처리되었습니다.