I have big trouble with my class library which is using to getting and sending text messenges through sockets. Here is my simple code :
private void AcceptNewSocket()
{
Socket socket = list.AcceptSocket();
socket.ReceiveBufferSize = 1001;
Thread socketTh = new Thread(new ThreadStart(AcceptNewSocket));
socketTh.Start();
WaitForMessenge(socket);
}
private void WaitForMessenge(Socket socket)
{
byte[] buff = new byte[1001];
int bufcount = socket.Receive(buff);
/////////some operations on byte array
while(bufcount > 0)
{
buffcount = socket.Receive(buff); //HERE it throws ObjectDisposedException and source is socket
/////some operations on byte array
}
}
There isn't any exception when i use my library in console application. It occurs when i use it in Windows Forms application. Can you help me ?