-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
The steps:
- Adapter is running successfully and gathering data.
- Agent connects to the adapter and collects data as expected.
- A telnet to the adapter port rejects any connection.
- The telnet connects as soon as the agent is stopped.
I think that the additional clients are in a queue till the connected client thread is terminated. Ref
Have tried to test the following code and seems to work. Please review.
private void HeartbeatClient(object client)
{
...
// Send intial stream to the client
SendAllTo(clientStream);
...
try
{
while (mRunning && tcpClient.Connected)
{
...
}
}
}
private void ListenForClients()
{
mRunning = true;
try
{
while (mRunning)
{
//create a thread to handle a new communication
Thread clientThread = new Thread(new ParameterizedThreadStart(HeartbeatClient));
//.AcceptTcpClient() blocks until a client has connected to the adapter
// a connection attaches the new client to the new thread
clientThread.Start(mListener.AcceptTcpClient());
}
}
catch (Exception e)
{
Console.WriteLine("Execption occurred waiting for connection: " + e.Message);
}
finally
{
mRunning = false;
mListener.Stop();
}
}
Metadata
Metadata
Assignees
Labels
No labels