Execution Problem
-
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
-
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
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.
-
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.
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 SideFileStream 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
-
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 SideFileStream 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
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.
-
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 SideFileStream 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
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
-
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
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
-
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
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
-
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
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
-
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
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