|
9 | 9 | using System.Collections.Generic; |
10 | 10 | using System.Diagnostics; |
11 | 11 | using System.IO; |
| 12 | +using System.Linq; |
12 | 13 | using System.Net; |
13 | 14 | using System.Net.Sockets; |
14 | 15 | using System.Net.Security; |
@@ -471,7 +472,7 @@ public int recv_into(ByteArray buffer, int nbytes=0, int flags=0) { |
471 | 472 | )] |
472 | 473 | public int recv_into(MemoryView buffer, int nbytes=0, int flags=0) { |
473 | 474 | int bytesRead; |
474 | | - byte[] byteBuffer = buffer.tobytes().ToByteArray(); |
| 475 | + byte[] byteBuffer = buffer.tobytes().ToArray(); |
475 | 476 | try { |
476 | 477 | bytesRead = _socket.Receive(byteBuffer, (SocketFlags)flags); |
477 | 478 | } |
@@ -556,7 +557,7 @@ public PythonTuple recvfrom_into(PythonArray buffer, int nbytes=0, int flags=0) |
556 | 557 | public PythonTuple recvfrom_into(MemoryView buffer, int nbytes=0, int flags=0){ |
557 | 558 |
|
558 | 559 | int bytesRead; |
559 | | - byte[] byteBuffer = buffer.tobytes().ToByteArray(); |
| 560 | + byte[] byteBuffer = buffer.tobytes().ToArray(); |
560 | 561 | IPEndPoint remoteIPEP = new IPEndPoint(IPAddress.Any, 0); |
561 | 562 | EndPoint remoteEP = remoteIPEP; |
562 | 563 |
|
@@ -636,7 +637,7 @@ private Exception MakeRecvException(Exception e, SocketError errorCode=SocketErr |
636 | 637 | + "had room to buffer your data for a network send" |
637 | 638 | )] |
638 | 639 | public int send(Bytes data, int flags=0) { |
639 | | - byte[] buffer = data.GetUnsafeByteArray(); |
| 640 | + byte[] buffer = data.UnsafeByteArray; |
640 | 641 | try { |
641 | 642 | return _socket.Send(buffer, (SocketFlags)flags); |
642 | 643 | } catch (Exception e) { |
@@ -693,11 +694,11 @@ public void sendall(string data, int flags=0) { |
693 | 694 | + "had room to buffer your data for a network send" |
694 | 695 | )] |
695 | 696 | public void sendall(Bytes data, int flags=0) { |
696 | | - sendallWorker(data.GetUnsafeByteArray(), flags); |
| 697 | + sendallWorker(data.UnsafeByteArray, flags); |
697 | 698 | } |
698 | 699 |
|
699 | 700 | public void sendall(MemoryView data, int flags = 0) { |
700 | | - sendallWorker(data.tobytes().GetUnsafeByteArray(), flags); |
| 701 | + sendallWorker(data.tobytes().UnsafeByteArray, flags); |
701 | 702 | } |
702 | 703 |
|
703 | 704 | private void sendallWorker(byte[] buffer, int flags) { |
@@ -757,7 +758,7 @@ public int sendto(string data, int flags, PythonTuple address) { |
757 | 758 | + "had room to buffer your data for a network send" |
758 | 759 | )] |
759 | 760 | public int sendto(Bytes data, int flags, PythonTuple address) { |
760 | | - byte[] buffer = data.GetUnsafeByteArray(); |
| 761 | + byte[] buffer = data.UnsafeByteArray; |
761 | 762 | EndPoint remoteEP = TupleToEndPoint(_context, address, _socket.AddressFamily, out _hostName); |
762 | 763 | try { |
763 | 764 | return _socket.SendTo(buffer, (SocketFlags)flags, remoteEP); |
@@ -1659,7 +1660,7 @@ public static string inet_ntop(CodeContext/*!*/ context, int addressFamily, Byte |
1659 | 1660 | )) { |
1660 | 1661 | throw PythonOps.ValueError("invalid length of packed IP address string"); |
1661 | 1662 | } |
1662 | | - byte[] ipBytes = packedIP.GetUnsafeByteArray(); |
| 1663 | + byte[] ipBytes = packedIP.UnsafeByteArray; |
1663 | 1664 | if (addressFamily == (int)AddressFamily.InterNetworkV6) { |
1664 | 1665 | return IPv6BytesToColonHex(ipBytes); |
1665 | 1666 | } |
@@ -2516,7 +2517,7 @@ Writes the string s into the SSL object. Returns the number |
2516 | 2517 | public int write(CodeContext/*!*/ context, Bytes data) { |
2517 | 2518 | EnsureSslStream(true); |
2518 | 2519 |
|
2519 | | - byte[] buffer = data.GetUnsafeByteArray(); |
| 2520 | + byte[] buffer = data.UnsafeByteArray; |
2520 | 2521 | try { |
2521 | 2522 | _sslStream.Write(buffer); |
2522 | 2523 | return buffer.Length; |
|
0 commit comments