Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

trondb

Cannot transfer a wave-file over a socket?!?

This topic is 5792 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I cannot get this to work. I am simply trying to transfer a wave file over a client/server connection using winsock! Its kinda weird because I am reading the file into a char* buffer at the server side, splitting it into chunks and transferring one at the time. Just to check, I also save those chunks to a file as I send them out on the socket. That file works just fine, but the file stored at the client side is corrupt... opening it up in a textviewer it looks pretty much the same, but is missing a few symbols here and there... The weird thing is that I am using exactly the same datatypes and sizes for the buffers, fileformats and so on on both sides, so I have no Idea what causes the data to go bad during the process... any ideas? I have the sourcecode at my site in case you have an idea what I am doing wrong: http://groups.msn.com/californiacornboy/Documents/Files/StreamCasterInternetRadio.zip Thanks again for all your time, you have been a great help! "That''s Tron. He fights for the users."

Share this post


Link to post
Share on other sites
Advertisement
Can''t download that unless you have an MSN Passport. I have one but it doesn''t work with my browser of choice. Can I suggest you find some other storage space, or perhaps post some code here? I can''t imagine your sending and receiving code would be too long.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post


Link to post
Share on other sites
Does the ''anomaly'' happen at certain intervals? Do they corespond with the lenght of the chunks you split the file?

Share this post


Link to post
Share on other sites
i cant see a pattern no, I have cleaned up my code, and it seems that it works for smaller files, but when they get larger, data gets corrupted, and chunks are lost even over TCP! I tried slowing down the sending, but that didnt help either...

"That''s Tron. He fights for the users."

Share this post


Link to post
Share on other sites
So you save it to a file at the receiving end... is that file the same size as the file that you sent?

Are you checking how many bytes send() and recv() actually did send? You may have told them to send/recv say 8192 bytes or whatever but that doesn''t mean they actually did.

I suggest you try sending a text file first. Fill this text file with text that will immediately be obvious if it wasn''t received properly, ie. something like:

ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
ABCDEFGHIJKLMNOPQRSTUVWXYZ012345679
....

Viewing the received version of this will give you a much clearer idea of what''s going on than looking at raw wav data
(You might need to make the text file very large to have a better chance of bringing up the same errors you had with the wav file.)

Share this post


Link to post
Share on other sites
Yeah thats a good idea! Thanks...
Well, it appears that there is no garble actually - but once I start sending files over a certain size, packets are lost. Files of size up to 90Kb work, but more than that no...

I send chunks of 128 bytes at a time, and count how many of these the client receive. The server might send something like 135 chunks, while the client only counts 134. For even bigger files, more chunks are lost. The number of lost chunks is consistent for every run of the program with the same file, though.... I also tried to change buffersize. Running with chunksize 8, I sent 21387 chunks but received only 21319. Thats 68 lost chunks * 8 = 544bytes that TCP lost? That is a lot for a guaranteed-delivery service like TCP isnt it? I have also tried to slow down my program in order to give the CPU, HD and network more time to see if that helped avoiding the errors, but it didnt help.



"That''s Tron. He fights for the users."

Share this post


Link to post
Share on other sites
Awesome, I really appreciate it! I know how demanding it can be to go through someone else''s code.

This problem is so confusing and frustrating to me, and I''ve worked my ass off trying to find the source of the instability.

"That''s Tron. He fights for the users."

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!