P
pbd22
Hi. I am getting the below error:
Event Type: Error
Event Source: PeskyService
Event Category: None
Event ID: 0
Date: 1/30/2008
Time: 5:49:10 PM
User: N/A
Computer: Computer
Description:
Only one usage of each socket address (protocol/network address/port)
is normally permitted
The service is starting (successfully) and then throwing this error
immediately after. It does this about 1,900 times in a very short
period of time and then throws an event log too full error.
I am not closing something when I should be - I feel. I have provided
the relevant methods (I think) showing where stuff gets opened and
closed.
The methods are:
protected override void OnStart(string[] args)
{
this.timer1.Enabled = true;
new Thread(new ThreadStart(Listen)).Start();
}
protected override void OnStop()
{
this.timer1.Enabled = false;
base.OnStop();
}
public void Listen()
{
Queue unsyncq = new Queue();
connectionQueue = Queue.Synchronized(unsyncq);
try
{
TcpListener listener = new TcpListener(_telnetServer,
_telnetPort);
listener.Start();
while (true)
{
_telnetSocket = listener.AcceptTcpClient();
connectionQueue.Enqueue(_telnetSocket);
Thread workingthread = new Thread(new
ThreadStart(TheConnectionHandler));
workingthread.Start();
}
}
catch (Exception e)
{
eventLog2.WriteEntry("Error in Listener:" + e.Message,
EventLogEntryType.Error);
return;
}
}
....
public void TheConnectionHandler()
{
_telnetSocket = (TcpClient)connectionQueue.Dequeue();
_clientStream = _telnetSocket.GetStream();
while (true)
{
_bytesRead = 0;
try
{
_bytesRead = _clientStream.Read(message, 0,
4096); //message
}
catch
{
//a socket error has occured
break;
}
if (_bytesRead == 0)
{
break;
}
statusMessage += ASCII.GetString(message, 0,
_bytesRead);
[SNIP]
_telnetSocket.Close();
_clientStream.Close();
}
Event Type: Error
Event Source: PeskyService
Event Category: None
Event ID: 0
Date: 1/30/2008
Time: 5:49:10 PM
User: N/A
Computer: Computer
Description:
Only one usage of each socket address (protocol/network address/port)
is normally permitted
The service is starting (successfully) and then throwing this error
immediately after. It does this about 1,900 times in a very short
period of time and then throws an event log too full error.
I am not closing something when I should be - I feel. I have provided
the relevant methods (I think) showing where stuff gets opened and
closed.
The methods are:
protected override void OnStart(string[] args)
{
this.timer1.Enabled = true;
new Thread(new ThreadStart(Listen)).Start();
}
protected override void OnStop()
{
this.timer1.Enabled = false;
base.OnStop();
}
public void Listen()
{
Queue unsyncq = new Queue();
connectionQueue = Queue.Synchronized(unsyncq);
try
{
TcpListener listener = new TcpListener(_telnetServer,
_telnetPort);
listener.Start();
while (true)
{
_telnetSocket = listener.AcceptTcpClient();
connectionQueue.Enqueue(_telnetSocket);
Thread workingthread = new Thread(new
ThreadStart(TheConnectionHandler));
workingthread.Start();
}
}
catch (Exception e)
{
eventLog2.WriteEntry("Error in Listener:" + e.Message,
EventLogEntryType.Error);
return;
}
}
....
public void TheConnectionHandler()
{
_telnetSocket = (TcpClient)connectionQueue.Dequeue();
_clientStream = _telnetSocket.GetStream();
while (true)
{
_bytesRead = 0;
try
{
_bytesRead = _clientStream.Read(message, 0,
4096); //message
}
catch
{
//a socket error has occured
break;
}
if (_bytesRead == 0)
{
break;
}
statusMessage += ASCII.GetString(message, 0,
_bytesRead);
[SNIP]
_telnetSocket.Close();
_clientStream.Close();
}