안녕하세요 소켓프로그램좀 봐주세요 ㅠ0ㅠ
글쓴이: segenny / 작성시간: 수, 2006/01/25 - 8:25오후
udp base 로 프로그램을 짜긴 했는데 속도가 시원치 않네요
/*Client BUFSIZE 1024 */
do{ if((rval = recvfrom(clientSocket , file_buffer , BUFLEN , 0 , (struct sockaddr*)&fromAddress , &from_len)) > 0) { fwrite(file_buffer , 1 , rval , fp); } else if (rval <0) { perror("Reading send file"); break; } }while(rval >0); /* do end */
/*Server BUFSIZE 1024 */
rval = read(fd,buf,BUFLEN); if( rval >= 0 ) { usleep(1); sendto(serverSocket , buf , rval , 0 , (struct sockaddr*)&clientAddress , sizeof(clientAddress)); } }while(rval >0);
입니다
그런데 클라이언트 파일에 쓰는 시간차 때문에 어쩔수 없이
서버 소스코드에 "usleep(1)" 넣었는데 화일은 손상없이 잘 값니다. 그런데 시간이..
700MB 는 30분 ㅠ0ㅠ 70MB 는 약 30초 ..(그것도 Local상)
입니다..
어떤 좋은방법이 없을까요..
아~ 다운로딩 할때 %나오는거 있잖아요 간단한 코드 어디없나요..
검색을 할때 키워드를 어케 해야하는지 모르겠네요..
하여튼 여기까지 읽어주셔서 감사합니다.. 매번 질문만 올리고
감사하단말.. 못하네요.. 수고하세요
Forums:
리눅스가 8192바이트정도가 속도에 있어서 최대버퍼사이즈였던거 같은데..
리눅스가 8192바이트정도가 속도에 있어서 최대버퍼사이즈였던거 같은데.. Sendto, revfrom()에 8192로 잡아보세요. (물론 버퍼도 저크기로 선언해야겠죠)
참 그리고 클라이언트에서 fwrite할때도 1씩 하지말고, 더 크게 잡아서 호출해보세요. (위와 같이 8192정도로 ^^)
God's Word is a lamp to my feet and a light for my path.
1) 큐를 만드세요.2) producer(수신)-consumer(파일
1) 큐를 만드세요.
2) producer(수신)-consumer(파일저장)하는 형태의 멀티프로세싱/쓰레딩을 고려하세요.
근데요
참 그리고 클라이언트에서 fwrite할때도 1씩 하지말고, 더 크게 잡아서 호출해보세요. (위와 같이 8192정도로 ^^)
이 부분에는 sizeof(char) 으로 지정해야되는데 구찮아서 그렇게 한거거든요
만약 1 이면 패킷사이즈르 1024
2 이면 패킷사이즈를 2048 로 하니깐 전송은 되는데
손실이 넘 많네요.. ㅠ0ㅠ
그리고 큐를 사용하라는것이 구체적으로 ㅠㅠ....
답변 감사합니다~~ `` ); 두분 ^^
* 큐1) recvfrom() --- fwrite()2) recv
* 큐
1) recvfrom() --- fwrite()
2) recvfrom() --- queueAdd()
recvfrom() 메모리에 환형큐(circular queue)등을 구현해서, 디스크에 쓰지 말고 메모리에 누적시킨다는 얘기입니다. 이를 다른 프로세스나 쓰레드에서 디스크로 쓰게합니다. 이러한 큐는 응용에 따라 메모리상에 구현하기도 하고, 별도의 프로세스로 만들기도 하고, 디스크 파일등으로 구현되기도 합니다.
질문자와 같은 경우 메모리로 구현하고, 테스트를 수행하여 적절한 큐의 크기를 산정하는게 좋겠습니다.
댓글 달기