KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > netbios > win32 > WinsockError


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.netbios.win32;
18
19 /**
20  * Winsock Error Codes Class
21  *
22  * <p>Contains a list of the error codes that the Win32 Winsock calls may generate, and a method to convert
23  * to an error text string.
24  *
25  * @author GKSpencer
26  */

27 public class WinsockError
28 {
29     // Winsock error code constants
30

31     public static final int WsaEIntr = 10004;
32     public static final int WsaEAcces = 10013;
33     public static final int WsaEFault = 10014;
34     public static final int WsaEInval = 10022;
35     public static final int WsaEMfile = 10024;
36     public static final int WsaEWouldBlock = 10035;
37     public static final int WsaEInProgress = 10036;
38     public static final int WsaEAlready = 10037;
39     public static final int WsaENotSock = 10038;
40     public static final int WsaEDestAddrReq = 10039;
41     public static final int WsaEMsgSize = 10040;
42     public static final int WsaEPrototype = 10041;
43     public static final int WsaENoProtoOpt = 10042;
44     public static final int WsaEProtoNoSupp = 10043;
45     public static final int WsaESocktNoSupp = 10044;
46     public static final int WsaEOpNotSupp = 10045;
47     public static final int WsaEPFNoSupport = 10046;
48     public static final int WsaEAFNoSupport = 10047;
49     public static final int WsaEAddrInUse = 10048;
50     public static final int WsaEAddrNotAvail= 10049;
51     public static final int WsaENetDown = 10050;
52     public static final int WsaENetUnReach = 10051;
53     public static final int WsaENetReset = 10052;
54     public static final int WsaEConnAborted = 10053;
55     public static final int WsaEConnReset = 10054;
56     public static final int WsaENoBufs = 10055;
57     public static final int WsaEIsConn = 10056;
58     public static final int WsaENotConn = 10057;
59     public static final int WsaEShutdown = 10058;
60     public static final int WsaETimedout = 10060;
61     public static final int WsaEConnRefused = 10061;
62     public static final int WsaEHostDown = 10064;
63     public static final int WsaEHostUnreach = 10065;
64     public static final int WsaEProcLim = 10067;
65     public static final int WsaSysNotReady = 10091;
66     public static final int WsaVerNotSupp = 10092;
67     public static final int WsaNotInit = 10093;
68     public static final int WsaEDiscon = 10101;
69     public static final int WsaTypeNotFound = 10109;
70     public static final int WsaHostNotFound = 11001;
71     public static final int WsaTryAgain = 11002;
72     public static final int WsaNoRecovery = 11003;
73     public static final int WsaNoData = 11004;
74     
75     /**
76      * Convert a Winsock error code to a text string
77      *
78      * @param sts int
79      * @return String
80      */

81     public static final String JavaDoc asString(int sts)
82     {
83         String JavaDoc errText = null;
84         
85         switch ( sts)
86         {
87         case WsaEIntr:
88             errText = "Interrupted function call";
89             break;
90         case WsaEAcces:
91             errText = "Permission denied";
92             break;
93         case WsaEFault:
94             errText = "Bad address";
95             break;
96         case WsaEInval:
97             errText = "Invalid argument";
98             break;
99         case WsaEMfile:
100             errText = "Too many open files";
101             break;
102         case WsaEWouldBlock:
103             errText = "Resource temporarily unavailable";
104             break;
105         case WsaEInProgress:
106             errText = "Operation now in progress";
107             break;
108         case WsaEAlready:
109             errText = "Operation already in progress";
110             break;
111         case WsaENotSock:
112             errText = "Socket operation on nonsocket";
113             break;
114         case WsaEDestAddrReq:
115             errText = "Destination address required";
116             break;
117         case WsaEMsgSize:
118             errText = "Message too long";
119             break;
120         case WsaEPrototype:
121             errText = "Protocol wrong type for socket";
122             break;
123         case WsaENoProtoOpt:
124             errText = "Bad protocol option";
125             break;
126         case WsaEProtoNoSupp:
127             errText = "Protocol not supported";
128             break;
129         case WsaESocktNoSupp:
130             errText = "Socket type not supported";
131             break;
132         case WsaEOpNotSupp:
133             errText = "Operation not supported";
134             break;
135         case WsaEPFNoSupport:
136             errText = "Protocol family not supported";
137             break;
138         case WsaEAFNoSupport:
139             errText = "Address family not supported by protocol family";
140             break;
141         case WsaEAddrInUse:
142             errText = "Address already in use";
143             break;
144         case WsaEAddrNotAvail:
145             errText = "Cannot assign requested address";
146             break;
147         case WsaENetDown:
148             errText = "Network is down";
149             break;
150         case WsaENetUnReach:
151             errText = "Network is unreachable";
152             break;
153         case WsaENetReset:
154             errText = "Network dropped connection on reset";
155             break;
156         case WsaEConnAborted:
157             errText = "Software caused connection abort";
158             break;
159         case WsaEConnReset:
160             errText = "Connection reset by peer";
161             break;
162         case WsaENoBufs:
163             errText = "No buffer space available";
164             break;
165         case WsaEIsConn:
166             errText = "Socket is already connected";
167             break;
168         case WsaENotConn:
169             errText = "Socket is not connected";
170             break;
171         case WsaEShutdown:
172             errText = "Cannot send after socket shutdown";
173             break;
174         case WsaETimedout:
175             errText = "Connection timed out";
176             break;
177         case WsaEConnRefused:
178             errText = "Connection refused";
179             break;
180         case WsaEHostDown:
181             errText = "Host is down";
182             break;
183         case WsaEHostUnreach:
184             errText = "No route to host";
185             break;
186         case WsaEProcLim:
187             errText = "Too many processes";
188             break;
189         case WsaSysNotReady:
190             errText = "Network subsystem is unavailable";
191             break;
192         case WsaVerNotSupp:
193             errText = "Winsock.dll version out of range";
194             break;
195         case WsaNotInit:
196             errText = "Successful WSAStartup not yet performed";
197             break;
198         case WsaEDiscon:
199             errText = "Graceful shutdown in progress";
200             break;
201         case WsaTypeNotFound:
202             errText = "Class type not found";
203             break;
204         case WsaHostNotFound:
205             errText = "Host not found";
206             break;
207         case WsaTryAgain:
208             errText = "Nonauthoritative host not found";
209             break;
210         case WsaNoRecovery:
211             errText = "This is a nonrecoverable error";
212             break;
213         case WsaNoData:
214             errText = "Valid name, no data record of requested type";
215             break;
216         default:
217             errText = "Unknown Winsock error 0x" + Integer.toHexString(sts);
218             break;
219         }
220         
221         return errText;
222     }
223 }
224
Popular Tags