@@ -148,10 +148,10 @@ public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size
148
148
var receiveCompleted = new ManualResetEvent ( false ) ;
149
149
var sendReceiveToken = new PartialSendReceiveToken ( socket , receiveCompleted ) ;
150
150
var args = new SocketAsyncEventArgs
151
- {
152
- RemoteEndPoint = socket . RemoteEndPoint ,
153
- UserToken = sendReceiveToken
154
- } ;
151
+ {
152
+ RemoteEndPoint = socket . RemoteEndPoint ,
153
+ UserToken = sendReceiveToken
154
+ } ;
155
155
args . Completed += ReceiveCompleted ;
156
156
args . SetBuffer ( buffer , offset , size ) ;
157
157
@@ -166,6 +166,10 @@ public static int ReadPartial(Socket socket, byte[] buffer, int offset, int size
166
166
"Socket read operation has timed out after {0:F0} milliseconds." ,
167
167
timeout . TotalMilliseconds ) ) ;
168
168
}
169
+ else
170
+ {
171
+ sendReceiveToken . Process ( args ) ;
172
+ }
169
173
170
174
if ( args . SocketError != SocketError . Success )
171
175
throw new SocketException ( ( int ) args . SocketError ) ;
@@ -359,10 +363,10 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS
359
363
var sendReceiveToken = new BlockingSendReceiveToken ( socket , buffer , offset , size , receiveCompleted ) ;
360
364
361
365
var args = new SocketAsyncEventArgs
362
- {
363
- UserToken = sendReceiveToken ,
364
- RemoteEndPoint = socket . RemoteEndPoint
365
- } ;
366
+ {
367
+ UserToken = sendReceiveToken ,
368
+ RemoteEndPoint = socket . RemoteEndPoint
369
+ } ;
366
370
args . Completed += ReceiveCompleted ;
367
371
args . SetBuffer ( buffer , offset , size ) ;
368
372
@@ -374,6 +378,10 @@ public static int Read(Socket socket, byte[] buffer, int offset, int size, TimeS
374
378
throw new SshOperationTimeoutException ( string . Format ( CultureInfo . InvariantCulture ,
375
379
"Socket read operation has timed out after {0:F0} milliseconds." , timeout . TotalMilliseconds ) ) ;
376
380
}
381
+ else
382
+ {
383
+ sendReceiveToken . Process ( args ) ;
384
+ }
377
385
378
386
if ( args . SocketError != SocketError . Success )
379
387
throw new SocketException ( ( int ) args . SocketError ) ;
@@ -443,6 +451,10 @@ public static void Send(Socket socket, byte[] data, int offset, int size)
443
451
if ( ! sendCompleted . WaitOne ( ) )
444
452
throw new SocketException ( ( int ) SocketError . TimedOut ) ;
445
453
}
454
+ else
455
+ {
456
+ sendReceiveToken . Process ( socketAsyncSendArgs ) ;
457
+ }
446
458
447
459
if ( socketAsyncSendArgs . SocketError != SocketError . Success )
448
460
throw new SocketException ( ( int ) socketAsyncSendArgs . SocketError ) ;
0 commit comments