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.

I don't see how that is relevant.

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.