2 // System.Net.Sockets.UdpClient.cs
5 // Rolf Bjarne Kvinge <rolf@xamarin.com>
7 // Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Threading.Tasks;
32 namespace System.Net.Sockets
34 public class UdpClient : IDisposable
36 const string EXCEPTION_MESSAGE = "System.Net.Sockets.UdpClient is not supported on the current platform.";
40 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
43 public UdpClient(AddressFamily family)
45 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
48 public UdpClient (int port)
50 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
53 public UdpClient (IPEndPoint localEP)
55 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
58 public UdpClient (int port, AddressFamily family)
60 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
63 public UdpClient (string hostname, int port)
65 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
70 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
73 public void Connect (IPEndPoint endPoint)
75 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
78 public void Connect (IPAddress addr, int port)
80 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
83 public void Connect (string hostname, int port)
85 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
88 public void DropMulticastGroup (IPAddress multicastAddr)
90 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
93 public void DropMulticastGroup (IPAddress multicastAddr, int ifindex)
95 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
98 public void JoinMulticastGroup (IPAddress multicastAddr)
100 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
103 public void JoinMulticastGroup (int ifindex, IPAddress multicastAddr)
105 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
108 public void JoinMulticastGroup (IPAddress multicastAddr, int timeToLive)
110 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
113 public void JoinMulticastGroup (IPAddress multicastAddr, IPAddress localAddress)
115 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
118 public byte [] Receive (ref IPEndPoint remoteEP)
120 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
123 public int Send (byte [] dgram, int bytes)
125 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
128 public int Send (byte [] dgram, int bytes, IPEndPoint endPoint)
130 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
133 public int Send (byte [] dgram, int bytes, string hostname, int port)
135 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
138 public IAsyncResult BeginSend (byte[] datagram, int bytes, AsyncCallback requestCallback, object state)
140 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
143 public IAsyncResult BeginSend (byte[] datagram, int bytes, IPEndPoint endPoint, AsyncCallback requestCallback, object state)
145 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
148 public IAsyncResult BeginSend (byte[] datagram, int bytes, string hostname, int port, AsyncCallback requestCallback, object state)
150 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
153 public int EndSend (IAsyncResult asyncResult)
155 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
158 public IAsyncResult BeginReceive (AsyncCallback requestCallback, object state)
160 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
163 public byte[] EndReceive (IAsyncResult asyncResult, ref IPEndPoint remoteEP)
165 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
168 protected bool Active {
169 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
170 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
173 public Socket Client {
174 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
175 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
178 public int Available {
179 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
182 public bool DontFragment {
183 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
184 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
187 public bool EnableBroadcast {
188 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
189 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
192 public bool ExclusiveAddressUse {
193 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
194 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
197 public bool MulticastLoopback {
198 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
199 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
203 get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
204 set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
207 public void Dispose ()
209 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
212 protected virtual void Dispose (bool disposing)
214 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
221 public Task<UdpReceiveResult> ReceiveAsync ()
223 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
226 public Task<int> SendAsync (byte[] datagram, int bytes)
228 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
231 public Task<int> SendAsync (byte[] datagram, int bytes, IPEndPoint endPoint)
233 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
236 public Task<int> SendAsync (byte[] datagram, int bytes, string hostname, int port)
238 throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);