i found solution usink Invoker change the server code
FileStream fs = new FileStream(@"c:\\jj.wav", FileMode.Create, FileAccess.Write);
sckt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
sckt.Bind(new IPEndPoint(0,08));
sckt.Listen(1);
acc = sckt.Accept();
sckt.Close();
new Thread(() =>
{
while (true)
{
byte[] sizebuffer = new byte[4];
acc.Receive(sizebuffer, 0, sizebuffer.Length, 0);
int size = BitConverter.ToInt32(sizebuffer, 0);
while (size > 0)
{
byte[] buffer;
if (size < acc.ReceiveBufferSize)
{
buffer = new byte[size];
}
else
buffer = new byte[acc.ReceiveBufferSize];
int rec = acc.Receive(buffer, 0, buffer.Length, 0);
size -= rec;
if (size < 0)
{ size = 0; }
fs.Write(buffer, 0, buffer.Length);
}
to
FileStream fs = new FileStream(@"c:\\jj.wav", FileMode.Create, FileAccess.Write);
sckt = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP);
sckt.Bind(new IPEndPoint(0,08));
sckt.Listen(1);
acc = sckt.Accept();
sckt.Close();
new Thread(() =>
{
while (true)
{
byte[] sizebuffer = new byte[4];
acc.Receive(sizebuffer, 0, sizebuffer.Length, 0);
int size = BitConverter.ToInt32(sizebuffer, 0);
while (size > 0)
{
byte[] buffer;
if (size < acc.ReceiveBufferSize)
{
buffer = new byte[size];
}
else
buffer = new byte[acc.ReceiveBufferSize];
int rec = acc.Receive(buffer, 0, buffer.Length, 0);
size -= rec;
if (size < 0)
{ size = 0; }
Invoke((MethodInvoker)delegate
{
fs.Write(buffer, 0, buffer.Length);
});
}