Skip to content

Commit 8f950c1

Browse files
committed
Closes #22, fixes not detecting socket disconnection
1 parent 3a4f14e commit 8f950c1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -266,4 +266,5 @@ __pycache__/
266266
/distribution
267267
nogit.config
268268
!/src/Globus.Kiosk/Binaries/*.dll
269-
BuildArtifacts/
269+
BuildArtifacts/
270+
NLog.config

source/ViceMonitor.Bridge/Righthand.ViceMonitor.Bridge/Services/Implementation/ViceBridge.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async Task StartAsync(int port, ISourceBlock<EnqueuedCommand> source, Cancellati
157157
logger.LogDebug("Waiting for available port");
158158
await WaitForPort(port, ct).ConfigureAwait(false);
159159
logger.LogDebug("Port acquired");
160-
socket.Connect("localhost", port);
160+
await socket.ConnectAsync("localhost", port, ct);
161161
logger.LogDebug("Port connected");
162162
if (socket.Connected)
163163
{
@@ -365,6 +365,15 @@ async Task LoopAsync(Socket socket, ISourceBlock<EnqueuedCommand> source, Cancel
365365
command.SetResult(response);
366366
}
367367
}
368+
else if (task == dataAvailableTask)
369+
{
370+
// when awaited dataAvailableTask expect data to be present
371+
// otherwise treat is as socket disconnected
372+
if (socket.Available == 0)
373+
{
374+
throw new SocketDisconnectedException("Socket disconnected based on no data received");
375+
}
376+
}
368377
while (socket.Available > 0)
369378
{
370379
await ProcessUnboundAsync(socket, ct);

0 commit comments

Comments
 (0)