mscorlib(4.0.0.0) API with additions
SendPacketsElement.cs
1 namespace System.Net.Sockets
2 {
4  public class SendPacketsElement
5  {
6  internal string m_FilePath;
7 
8  internal byte[] m_Buffer;
9 
10  internal int m_Offset;
11 
12  internal int m_Count;
13 
14  internal UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags m_Flags;
15 
18  public string FilePath => m_FilePath;
19 
22  public byte[] Buffer => m_Buffer;
23 
26  public int Count => m_Count;
27 
30  public int Offset => m_Offset;
31 
34  public bool EndOfPacket => (m_Flags & UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags.EndOfPacket) != UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags.None;
35 
36  private SendPacketsElement()
37  {
38  }
39 
43  public SendPacketsElement(string filepath)
44  : this(filepath, 0, 0, endOfPacket: false)
45  {
46  }
47 
54  public SendPacketsElement(string filepath, int offset, int count)
55  : this(filepath, offset, count, endOfPacket: false)
56  {
57  }
58 
66  public SendPacketsElement(string filepath, int offset, int count, bool endOfPacket)
67  {
68  if (filepath == null)
69  {
70  throw new ArgumentNullException("filepath");
71  }
72  if (offset < 0)
73  {
74  throw new ArgumentOutOfRangeException("offset");
75  }
76  if (count < 0)
77  {
78  throw new ArgumentOutOfRangeException("count");
79  }
80  Initialize(filepath, null, offset, count, UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags.File, endOfPacket);
81  }
82 
86  public SendPacketsElement(byte[] buffer)
87  : this(buffer, 0, (buffer != null) ? buffer.Length : 0, endOfPacket: false)
88  {
89  }
90 
97  public SendPacketsElement(byte[] buffer, int offset, int count)
98  : this(buffer, offset, count, endOfPacket: false)
99  {
100  }
101 
109  public SendPacketsElement(byte[] buffer, int offset, int count, bool endOfPacket)
110  {
111  if (buffer == null)
112  {
113  throw new ArgumentNullException("buffer");
114  }
115  if (offset < 0 || offset > buffer.Length)
116  {
117  throw new ArgumentOutOfRangeException("offset");
118  }
119  if (count < 0 || count > buffer.Length - offset)
120  {
121  throw new ArgumentOutOfRangeException("count");
122  }
123  Initialize(null, buffer, offset, count, UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags.Memory, endOfPacket);
124  }
125 
126  private void Initialize(string filePath, byte[] buffer, int offset, int count, UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags flags, bool endOfPacket)
127  {
128  m_FilePath = filePath;
129  m_Buffer = buffer;
130  m_Offset = offset;
131  m_Count = count;
132  m_Flags = flags;
133  if (endOfPacket)
134  {
135  m_Flags |= UnsafeNclNativeMethods.OSSOCK.TransmitPacketsElementFlags.EndOfPacket;
136  }
137  }
138  }
139 }
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Represents an element in a T:System.Net.Sockets.SendPacketsElement array.
string FilePath
Gets the filename of the file to send if the T:System.Net.Sockets.SendPacketsElement class was initia...
SendPacketsElement(byte[] buffer, int offset, int count, bool endOfPacket)
Initializes a new instance of the T:System.Net.Sockets.SendPacketsElement class using the specified b...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
SendPacketsElement(byte[] buffer, int offset, int count)
Initializes a new instance of the T:System.Net.Sockets.SendPacketsElement class using the specified b...
SendPacketsElement(string filepath, int offset, int count)
Initializes a new instance of the T:System.Net.Sockets.SendPacketsElement class using the specified f...
int Count
Gets the count of bytes to be sent.
SendPacketsElement(string filepath, int offset, int count, bool endOfPacket)
Initializes a new instance of the T:System.Net.Sockets.SendPacketsElement class using the specified f...
bool EndOfPacket
Gets a Boolean value that indicates if this element should not be combined with the next element in a...
SendPacketsElement(string filepath)
Initializes a new instance of the T:System.Net.Sockets.SendPacketsElement class using the specified f...
int Offset
Gets the offset, in bytes, from the beginning of the data buffer or file to the location in the buffe...
Manipulates arrays of primitive types.
Definition: Buffer.cs:11