[C# Socket ] 파일전송중 Client 가 죽은것 알아채기 2


파일 전송중에 클라이언트가 죽은것을 알아채는 방법
타이머를 이용하여 받은 지금까지 받은 바이트 길이의 변화량이 일정시간 동안 변경이 없을때,
종료하면 된다.

 
int contentByteLength = 0;
            int totalbytelength;
                        
            bool exitCheck = false;
            int checkIntValue = 0;

            checkTimer = new Timer(1000);
            checkTimer.Elapsed += delegate 
            {
                if (checkIntValue == contentByteLength)
                {
                    Console.WriteLine("check!");
                    exitCheck = true;
                    checkTimer.Dispose();
                    checkTimer.Close();
                    checkTimer = null;
                }

                Console.WriteLine("Ele" + contentByteLength + " " + System.Threading.Thread.CurrentThread.ManagedThreadId);
                checkIntValue = contentByteLength;
            };
            
            checkTimer.Start();

            FileStream fs = new FileStream(@"c:\test\" + name + ".zip", FileMode.OpenOrCreate, FileAccess.Write);
            while (contentByteLength < totalbytelength)
            {
                if (client.Available > 0)
                {
                    byte[] receive = new byte[client.Available];
                    client.Receive(receive);
                    fs.Write(receive, 0, receive.Length);
                    contentByteLength += receive.Length;
                    
                }
                
                if (exitCheck)
                {
                    break;
                }
            }




            fs.Close();
            client.Close();
            Console.WriteLine("end! " + contentByteLength + " " );

            

Yamecoder 야매코더_
C# 2012. 2. 12. 19:58

댓글을 달아 주세요

  1. 이전 댓글 더보기
  2. BlogIcon Moncler Jackets Woman 2014.12.30 08:19  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  3. BlogIcon furla handbags 2015.01.18 00:22  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  4. BlogIcon mont blanc watches 2015.01.20 17:50  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  5. 匿名 2015.01.26 19:48  수정/삭제  댓글쓰기

    이용약관위배로 관리자 삭제된 댓글입니다.

  6. BlogIcon tory burch reva 2015.02.20 13:58  수정/삭제  댓글쓰기

    법뉴and become a much better servant

    End up being humbled to become offered, and become a much better servant

    The month of january 28, 2007By Rev. At the Goudy, Unique towards the Early morning Phone Freelance

    This has become the the majority of fashionable bit of clothes I've actually put on. Their own mom experienced died as well as We had been graciously asked to put on the actual clothing로리

  7. BlogIcon Cheap Macbook 2015.03.16 09:00  수정/삭제  댓글쓰기

    니는Info:

    Name: Ellie Park

    Looks: girl blonde

    hair/Animemusicemofreak/Anime/Girl/Blonde Hair/21053521712063122923.jpg?o=71 and she's 5"1

    Type of trainer: Coordinator

    Crush: Drew

    Pokemon: Cyndaquil (starter, which refuses to evolve [much like Dawn's Piplup]), Beautifly, Gardevoir, Espeon, Skarmory

    Other: Takes place in Johto. Ellie has competed in many contests and all the grand f가습

  8. BlogIcon oakley sunglassses outlet 2015.03.18 21:30  수정/삭제  댓글쓰기

    의로Produce Phase Chance TPI regarding Muscle tissue Soreness

    Meaning the actual treat will stay on your computer even though an individual depart as well as close to your personal web browser that might decrease your levels of solitude in addition to safety. You should not select this process if you're employing a freely accessible computer, or even even though you tend to be talking about a pc as려있

  9. BlogIcon portefeuille louis vuitton 2015.03.18 21:58  수정/삭제  댓글쓰기

    에기Sydney's homeless offered a helping hand 05

    ELEANOR HALL: Homeless and disadvantaged people in Sydney's CBD are being offered a helping hand today,discount oakley sunglasses. Volunteers are offering a range of services from haircuts to a hot lunch.

    Sydney Homeless Connect is in its third year and aims to help more than 3, 000 people.

    ANDREW EVERINGHAM: We've got the homeless sector servic선데

  10. BlogIcon furla bags 2015.03.26 02:09  수정/삭제  댓글쓰기

    법선Compering The True And Fake Replica Watches

    Probably the most popular Swiss made watches can be an outstanding brand that is known as Replica. These timepieces are distinctive for their unique design and excellence of handmade performance. The arrangement of such watches vary and corresponds to different tastes and preferences. Purchasing this wrist watch you can be sure that you simply obtain 데런

  11. BlogIcon chemise homme burberry pas cher 2015.03.27 21:10  수정/삭제  댓글쓰기

    있일"Jun non tr&egrave;s sombre.
    ils sont prts &agrave; acheter, Mao Zedong, qu'est - il arriv&eacute;? des deux ct&eacute;s de l'&eacute;tablissement. dense, l'empereur de la reine &agrave; envoyer des fonctionnaires. "Dragon".Les gens sous son r&egrave;gne, mais personne ne m'&eacute;coute.avec burberry echarpe la terre du roi certains repr&eacute;sentants &agrave; Harbin et le sud de Beijing.
    p뉴지

  12. BlogIcon furla online 2015.03.29 14:59  수정/삭제  댓글쓰기

    법일Hells Angels can't keep Toronto clubhouse says Ontario's top court

    The Hells Angels new balance outlet Motorcycle Club has lost a bid to hang on to their old clubhouse on Eastern Ave.

    The Ontario Court of Appeal quashed a court challenge on Friday new balance running shoes by the bikers to win back their fortified oakley outlet clubhouse in the east end near the Don Valley Parkway.

    The cl리지

  13. BlogIcon burberry homme enfant pas cher 2015.03.30 11:27  수정/삭제  댓글쓰기

    그리s'il n'y a pas d'entrer dans l'histoire Manchu la Chine va comment?|



    | nous supposons maintenant que

    , Li Wu Li Zicheng l'occupation de P&eacute;kin, la reddition, bloquant ainsi la Duo Ergun, entr&eacute;e dans le mme temps, Li Zicheng poss&egrave;de un champ de vision et de la Strat&eacute;gie internationale, sciences pr&eacute;voyait Qing est l'ennemi num&eacute;ro un, et l'itin&eacut가리

  14. BlogIcon tee shirt burberry homme 2015.03.31 00:03  수정/삭제  댓글쓰기

    있없URL aIci,trench burberry homme pas cher,http://basketburberrypascher.moonfruit.fr相关的主题文章:


    相关的主题文章:일는

  15. 匿名 2015.03.31 08:50  수정/삭제  댓글쓰기

    어알There are several benefits of this process such as consumers have bargaining power. They can have the benefit of a wide range of choice. The consumers find it more difficult in managing a channel which is non-digital. It enhances commoditization. There is a threat for new competitors. Introducing new products is quite easy as it needs less over-heads. There is a fear of substitutes and there is co는어

  16. 匿名 2015.04.01 06:28  수정/삭제  댓글쓰기

    데우火车采集器html简单模板示范






    What You Should Check Before Going to a Motorcycle Trip







    [标签:来源]








    Motorcycle trips are exciting. It is easy to get to a certain place. Aside from that,Motorcycle Helmet_117626, you can enjoy the view. You can easily stop to enjoy it as well. However, these types of trips need extensive planning. You have to plan where to go, what to do and기들

  17. BlogIcon cheap oakley sunglasses 2015.04.01 21:03  수정/삭제  댓글쓰기

    리상happens to be an issue

    Whilst Western as well as United states need continues to be mostly as well as at any time buoyant, the actual starving Hard anodized cookware marketplaces tend to be consuming luxurious Traditional western products as though these people losing sight of style. The far east list product sales flower with a massive eighteen. 7 percent this past year, carrying out a 15. two표지

  18. 匿名 2015.04.03 17:37  수정/삭제  댓글쓰기

    는기If you are looking to insure a classic or vintage car in the Chicago area, the Chicago insurance agents of Insure on the Spot may be able to help. For more information on classic car insurance,Situations That Call For Medi, visit the website of Insure on the Spot.





    火车采集器html简单模板示范







    Insurance provides coverage if you car is stolen, or if it is vandalized. In addition, covera선표

  19. BlogIcon tory burch reva flats 2015.04.03 22:10  수정/삭제  댓글쓰기

    리에Research Protocol Development

    Prerequisites are the course(s) that must have been previously passed to be able to enrol in a particular course. A prerequisite course provides the appropriate foundation knowledge in order oakley sunglasses outlet to progress to the next course. For students who intend to enrol in a Dissertation (8 units of research) or a Project (4 units of research) as part of 리지

  20. 匿名 2015.04.04 02:54  수정/삭제  댓글쓰기

    되습Black and military green. Each shoe has a cap of products 100% nylon with white leather on the tip, with white vulcanized sole. The following is a list detailing details log on to Nike Air Max 90.



    You could in a project file for the planning office is purpose Used MBT Women's Lami investment.Find ultimate solution for intelligent and affordable new and used office furniture.


    Here are s히런

  21. 匿名 2015.04.09 00:24  수정/삭제  댓글쓰기

    마메Known publishers from the foreign press, secular, artists, designers and fashionsitas, everybody came from the collection of women Moncler Marmelade Techno equipped with seat belts parka to be seen. They are all "oohed and ahhed" while enjoying hot cider and hot chocolate. Personally.



    Ironic how the absence of life (which is visual, with them being completely immobile), the scene so alive! 일에

Powerd by Tistory, designed by criuce
rss