IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
SocketExceptionExtensions.cs
Go to the documentation of this file.
1using System;
2using System.Net.Sockets;
3
5{
6
11 {
12
13#if !FIRST_PASS
14
21 public static global::java.io.IOException ToIOException(this SocketException self)
22 {
23 if (self is null)
24 throw new ArgumentNullException(nameof(self));
25
26 switch (self.SocketErrorCode)
27 {
28 case SocketError.Interrupted:
29 throw new global::java.io.InterruptedIOException(self.Message);
30 case SocketError.AddressAlreadyInUse:
31 case SocketError.AddressNotAvailable:
32 case SocketError.AccessDenied:
33 return new global::java.net.BindException(self.Message);
34 case SocketError.NetworkUnreachable:
35 case SocketError.HostUnreachable:
36 return new global::java.net.NoRouteToHostException(self.Message);
37 case SocketError.TimedOut:
38 return new global::java.net.SocketTimeoutException(self.Message);
39 case SocketError.ConnectionRefused:
40 return new global::java.net.PortUnreachableException(self.Message);
41 case SocketError.ConnectionReset:
42 return new global::sun.net.ConnectionResetException(self.Message);
43 case SocketError.HostNotFound:
44 return new global::java.net.UnknownHostException(self.Message);
45 case SocketError.ProtocolNotSupported:
46 return new global::java.net.ProtocolException(self.Message);
47 default:
48 return new global::java.net.SocketException($"{self.Message} [{self.SocketErrorCode}]");
49 }
50 }
51
52#endif
53
54 }
55
56}
static global::java.io.IOException ToIOException(this SocketException self)
Converts the given SocketException to a global::java.io.IOException.