Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Execution Problem

Execution Problem

Scheduled Pinned Locked Moved C#
helpsysadmindebuggingtutorialquestion
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DeepOceans
    wrote on last edited by
    #1

    Hi I m getting a problem while executing my program. Actually I m trying to send video file from server to client using BufferedStream with TCP. When I debug it,program runs fine and exact video is recieved on the client side. But when I run prog. normally(without Debugging),I get Corrupted video.I m not getting a clue on how this file corrupts when I run normally as this doesn't happen While I debug. PLZZZZZZZZZ TELL ME ASAP WHAT IS THIS ERROR AND HOW TO RESOLVE IT. Regards,

    Shanzay

    A 1 Reply Last reply
    0
    • D DeepOceans

      Hi I m getting a problem while executing my program. Actually I m trying to send video file from server to client using BufferedStream with TCP. When I debug it,program runs fine and exact video is recieved on the client side. But when I run prog. normally(without Debugging),I get Corrupted video.I m not getting a clue on how this file corrupts when I run normally as this doesn't happen While I debug. PLZZZZZZZZZ TELL ME ASAP WHAT IS THIS ERROR AND HOW TO RESOLVE IT. Regards,

      Shanzay

      A Offline
      A Offline
      Adeel Chaudhry
      wrote on last edited by
      #2

      Hi, Read the file till end into the buffer, and then try sending it. Regards, Adeel

      Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

      D 1 Reply Last reply
      0
      • A Adeel Chaudhry

        Hi, Read the file till end into the buffer, and then try sending it. Regards, Adeel

        Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

        D Offline
        D Offline
        DeepOceans
        wrote on last edited by
        #3

        I m sending through streaming by using 16KB buffer as: //Sending Side byte buf = new byte[16384]; FileStream inStream = File.OpenRead(dlgOpen.FileName); BufferedStream bufInStream = new BufferedStream(inStream); int bytesRead; while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) sock.Send(buf,buf.Length,SocketFlags.None); ///////////////////////////////////// At Recieving Side FileStream outStream; outStream=File.OpenWrite(filepath); rcvfilebuf=new byte[16384]; while(true) { socket.Receive(rcvfilebuf); bufOutStream = new BufferedStream(outStream); bufOutStream.Write(rcvfilebuf, 0, rcvfilebuf.Length); } This code is doing well while debugging but not in normal running of application.

        Shanzay

        A L 2 Replies Last reply
        0
        • D DeepOceans

          I m sending through streaming by using 16KB buffer as: //Sending Side byte buf = new byte[16384]; FileStream inStream = File.OpenRead(dlgOpen.FileName); BufferedStream bufInStream = new BufferedStream(inStream); int bytesRead; while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) sock.Send(buf,buf.Length,SocketFlags.None); ///////////////////////////////////// At Recieving Side FileStream outStream; outStream=File.OpenWrite(filepath); rcvfilebuf=new byte[16384]; while(true) { socket.Receive(rcvfilebuf); bufOutStream = new BufferedStream(outStream); bufOutStream.Write(rcvfilebuf, 0, rcvfilebuf.Length); } This code is doing well while debugging but not in normal running of application.

          Shanzay

          A Offline
          A Offline
          Adeel Chaudhry
          wrote on last edited by
          #4

          Hi, Tried without reading in buffers? Reading the whole file in one I/O operation, and then sending it might solve the issue. Regards, Adeel

          Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

          1 Reply Last reply
          0
          • D DeepOceans

            I m sending through streaming by using 16KB buffer as: //Sending Side byte buf = new byte[16384]; FileStream inStream = File.OpenRead(dlgOpen.FileName); BufferedStream bufInStream = new BufferedStream(inStream); int bytesRead; while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) sock.Send(buf,buf.Length,SocketFlags.None); ///////////////////////////////////// At Recieving Side FileStream outStream; outStream=File.OpenWrite(filepath); rcvfilebuf=new byte[16384]; while(true) { socket.Receive(rcvfilebuf); bufOutStream = new BufferedStream(outStream); bufOutStream.Write(rcvfilebuf, 0, rcvfilebuf.Length); } This code is doing well while debugging but not in normal running of application.

            Shanzay

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            The problem is at the receiving end, your file is too large. What will the value be of rcvfilebuf.Length? Doesn't Socket.Receive return something? :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            D 1 Reply Last reply
            0
            • L Luc Pattyn

              The problem is at the receiving end, your file is too large. What will the value be of rcvfilebuf.Length? Doesn't Socket.Receive return something? :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


              D Offline
              D Offline
              DeepOceans
              wrote on last edited by
              #6

              Yah it returns and its size is 16KB.And I've solved this problem by using thread.sleep(30) before send() from server side but now the file which I m getting at client side the frames of that video file are overlapping so what to do in this case as if File size 10MB then it gives required output but if larger than 20MB then frames becomes overlap in video. So PLZ SUGGEST NOW How to solve this:( Thanx

              Shanzay

              L 1 Reply Last reply
              0
              • D DeepOceans

                Yah it returns and its size is 16KB.And I've solved this problem by using thread.sleep(30) before send() from server side but now the file which I m getting at client side the frames of that video file are overlapping so what to do in this case as if File size 10MB then it gives required output but if larger than 20MB then frames becomes overlap in video. So PLZ SUGGEST NOW How to solve this:( Thanx

                Shanzay

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                DeepOceans wrote:

                Yah it returns and its size is 16KB

                I don't think so. If the sender's file size is a multiple of 16KB, then all buffers will contain 16KB. If the sender's file size is not a multiple of 16KB, the last buffer sent will contain less, but the receiver, the way you did it, will still store 16KB, i.e. the buffer will contain some older data and write that to the file too. That's what my previous reply was about. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


                D 1 Reply Last reply
                0
                • L Luc Pattyn

                  DeepOceans wrote:

                  Yah it returns and its size is 16KB

                  I don't think so. If the sender's file size is a multiple of 16KB, then all buffers will contain 16KB. If the sender's file size is not a multiple of 16KB, the last buffer sent will contain less, but the receiver, the way you did it, will still store 16KB, i.e. the buffer will contain some older data and write that to the file too. That's what my previous reply was about. :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


                  D Offline
                  D Offline
                  DeepOceans
                  wrote on last edited by
                  #8

                  I handle this issue at Server(sending side)but didnt mention before as like this: while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) if(bytesRead<16384) sock.Send(buf,bytesRead,SocketFlags.None); else sock.Send(buf,buf.Length,SocketFlags.None); so then by this way client recieves data though in 16KB buffer but I got success in playing 10MB file at client side.but now file size of more than 15MB is not playing properly. In this case frames are overlapping so what is prob. here?

                  Shanzay

                  L 1 Reply Last reply
                  0
                  • D DeepOceans

                    I handle this issue at Server(sending side)but didnt mention before as like this: while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) if(bytesRead<16384) sock.Send(buf,bytesRead,SocketFlags.None); else sock.Send(buf,buf.Length,SocketFlags.None); so then by this way client recieves data though in 16KB buffer but I got success in playing 10MB file at client side.but now file size of more than 15MB is not playing properly. In this case frames are overlapping so what is prob. here?

                    Shanzay

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    DeepOceans wrote:

                    while ((bytesRead = bufInStream.Read( buf, 0, 16384)) > 0) if(bytesRead<16384) sock.Send(buf,bytesRead,SocketFlags.None); else sock.Send(buf,buf.Length,SocketFlags.None);

                    this is not my point; and it is a useless complication, just write sock.Send(buf,bytesRead,SocketFlags.None); You should fix the receiver! :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    this months tips: - before you ask a question here, search CodeProject, then Google - the quality and detail of your question reflects on the effectiveness of the help you are likely to get - use PRE tags to preserve formatting when showing multi-line code snippets


                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups