954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

[C#] .mp3 File Transfer Help

Hello, I am currently trying to create a server/client file transfer system in which the server sends the client .mp3 files. The file transfers fine but when I go to play the file, it is all scratchy and skips and I think it has something to do with the bytes that I am sending.

Here is the server code:

byte[] fileData = File.ReadAllBytes(sData);
                       byte[] clientData = new byte[4 + fileData.Length];
                       fileData.CopyTo(clientData, 4);

                       socketData.m_currentSocket.Send(clientData);


Here is the client code:

SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
                byte[] clientData = new byte[1024 * 5000];

                int receivedBytesLen = theSockId.thisSocket.Receive(clientData);

                //int fileNameLen = BitConverter.ToInt32(clientData, 0);

                BinaryWriter bWrite = new BinaryWriter(File.Open(@"C:\TEMP\Test.mp3", FileMode.Append, FileAccess.Write));
                bWrite.Write(clientData, 4, receivedBytesLen + 1);

                bWrite.Close();


Please help me find out why the music file is scratchy.

Thank you,

Bapes.

Bapes
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

I don't see how that is relevant.

Bapes
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

Update: I tried removing the 4+ to the byte and setting the start index to 0, but now the file gets very distorted and the name is messed up. Also, the file size isn't the same.

Bapes
Newbie Poster
3 posts since Apr 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: