Imported Upstream version 6.0.0.172

Former-commit-id: f3cc9b82f3e5bd8f0fd3ebc098f789556b44e9cd
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-04-12 14:10:50 +00:00
parent 8016999e4d
commit 64ac736ec5
32155 changed files with 3981439 additions and 75368 deletions

View File

@ -939,7 +939,7 @@ namespace System.Net.Sockets
throw new ArgumentNullException("e");
if (e.in_progress != 0 && e.LastOperation == SocketAsyncOperation.Connect)
e.current_socket.Close();
e.current_socket?.Close ();
}
static AsyncCallback ConnectAsyncCallback = new AsyncCallback (ares => {
@ -1391,6 +1391,8 @@ namespace System.Net.Sockets
return ret;
}
public int Receive (Span<byte> buffer) => Receive (buffer, SocketFlags.None);
public bool ReceiveAsync (SocketAsyncEventArgs e)
{
// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
@ -1882,6 +1884,8 @@ namespace System.Net.Sockets
return Send (buffer.ToArray(), socketFlags);
}
public int Send (ReadOnlySpan<byte> buffer) => Send (buffer, SocketFlags.None);
public bool SendAsync (SocketAsyncEventArgs e)
{
// NO check is made whether e != null in MS.NET (NRE is thrown in such case)
@ -2604,14 +2608,26 @@ namespace System.Net.Sockets
public void Shutdown (SocketShutdown how)
{
const int enotconn = 10057;
ThrowIfDisposedAndClosed ();
if (!is_connected)
throw new SocketException (10057); // Not connected
throw new SocketException (enotconn); // Not connected
int error;
Shutdown_internal (m_Handle, how, out error);
if (error == enotconn) {
// POSIX requires this error to be returned from shutdown in some cases,
// even if the socket is actually connected.
// We have already checked is_connected so it isn't meaningful or useful for
// us to throw if the OS says the socket was already closed when we tried to
// shut it down.
// See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227259
return;
}
if (error != 0)
throw new SocketException (error);
}