Skip to content

Commit 3234a50

Browse files
authored
Merge cb7d4b5 into 45672e0
2 parents 45672e0 + cb7d4b5 commit 3234a50

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Fleck/Interfaces/ISocket.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public interface ISocket
1919

2020
Task<ISocket> Accept(Action<ISocket> callback, Action<Exception> error);
2121
Task Send(byte[] buffer, Action callback, Action<Exception> error);
22+
Task Send(byte[] buffer, int offset, int length, Action callback, Action<Exception> error);
2223
Task<int> Receive(byte[] buffer, Action<int> callback, Action<Exception> error, int offset = 0);
2324
Task Authenticate(X509Certificate2 certificate, SslProtocols enabledSslProtocols, Action callback, Action<Exception> error);
2425

src/Fleck/SocketWrapper.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ namespace Fleck
1414
{
1515
public class SocketWrapper : ISocket
1616
{
17-
17+
1818
public const UInt32 KeepAliveInterval = 60000;
1919
public const UInt32 RetryInterval = 10000;
20-
20+
2121
private readonly Socket _socket;
2222
private Stream _stream;
2323
private CancellationTokenSource _tokenSource;
@@ -166,14 +166,18 @@ public int EndSend(IAsyncResult asyncResult)
166166
}
167167

168168
public Task Send(byte[] buffer, Action callback, Action<Exception> error)
169+
{
170+
return Send(buffer, 0, buffer.Length, callback, error);
171+
}
172+
public Task Send(byte[] buffer, int offset, int length, Action callback, Action<Exception> error)
169173
{
170174
if (_tokenSource.IsCancellationRequested)
171175
return null;
172176

173177
try
174178
{
175179
Func<AsyncCallback, object, IAsyncResult> begin =
176-
(cb, s) => _stream.BeginWrite(buffer, 0, buffer.Length, cb, s);
180+
(cb, s) => _stream.BeginWrite(buffer, offset, length, cb, s);
177181

178182
Task task = Task.Factory.FromAsync(begin, _stream.EndWrite, null);
179183
task.ContinueWith(t => callback(), TaskContinuationOptions.NotOnFaulted)

0 commit comments

Comments
 (0)