Produced by Araxis Merge on 9/25/2018 2:13:09 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\java\net | SocketImpl.java | Mon Jan 22 14:46:52 2018 UTC |
2 | build 3.zip\build 3\MHLTH_YS_137_Source\JavaScript\resources\javaJDF-1.8.0\src\java\net | SocketImpl.java | Wed Sep 12 17:09:53 2018 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 2 | 792 |
Changed | 1 | 4 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | /* | |
2 | * Copyrig ht (c) 199 5, 2013, O racle and/ or its aff iliates. A ll rights reserved. | |
3 | * DO NOT ALTER OR R EMOVE COPY RIGHT NOTI CES OR THI S FILE HEA DER. | |
4 | * | |
5 | * This co de is free software; you can r edistribut e it and/o r modify i t | |
6 | * under t he terms o f the GNU General Pu blic Licen se version 2 only, a s | |
7 | * publish ed by the Free Softw are Founda tion. Ora cle design ates this | |
8 | * particu lar file a s subject to the "Cl asspath" e xception a s provided | |
9 | * by Orac le in the LICENSE fi le that ac companied this code. | |
10 | * | |
11 | * This co de is dist ributed in the hope that it wi ll be usef ul, but WI THOUT | |
12 | * ANY WAR RANTY; wit hout even the implie d warranty of MERCHA NTABILITY or | |
13 | * FITNESS FOR A PAR TICULAR PU RPOSE. Se e the GNU General Pu blic Licen se | |
14 | * version 2 for mor e details (a copy is included in the LIC ENSE file that | |
15 | * accompa nied this code). | |
16 | * | |
17 | * You sho uld have r eceived a copy of th e GNU Gene ral Public License v ersion | |
18 | * 2 along with this work; if not, write to the Fr ee Softwar e Foundati on, | |
19 | * Inc., 5 1 Franklin St, Fifth Floor, Bo ston, MA 0 2110-1301 USA. | |
20 | * | |
21 | * Please contact Or acle, 500 Oracle Par kway, Redw ood Shores , CA 94065 USA | |
22 | * or visi t www.orac le.com if you need a dditional informatio n or have any | |
23 | * questio ns. | |
24 | */ | |
25 | ||
26 | package ja va.net; | |
27 | ||
28 | import jav a.io.IOExc eption; | |
29 | import jav a.io.Input Stream; | |
30 | import jav a.io.Outpu tStream; | |
31 | import jav a.io.FileD escriptor; | |
32 | ||
33 | /** | |
34 | * The abs tract clas s {@code S ocketImpl} is a comm on supercl ass | |
35 | * of all classes th at actuall y implemen t sockets. It is use d to | |
36 | * create both clien t and serv er sockets . | |
37 | * <p> | |
38 | * A "plai n" socket implements these met hods exact ly as | |
39 | * describ ed, withou t attempti ng to go t hrough a f irewall or proxy. | |
40 | * | |
41 | * @author unascrib ed | |
42 | * @since JDK1.0 | |
43 | */ | |
44 | public abs tract clas s SocketIm pl impleme nts Socket Options { | |
45 | /** | |
46 | * The actual So cket objec t. | |
47 | */ | |
48 | Socket socket = null; | |
49 | Server Socket ser verSocket = null; | |
50 | ||
51 | /** | |
52 | * The file desc riptor obj ect for th is socket. | |
53 | */ | |
54 | protec ted FileDe scriptor f d; | |
55 | ||
56 | /** | |
57 | * The IP addres s of the r emote end of this so cket. | |
58 | */ | |
59 | protec ted InetAd dress addr ess; | |
60 | ||
61 | /** | |
62 | * The port numb er on the remote hos t to which this sock et is conn ected. | |
63 | */ | |
64 | protec ted int po rt; | |
65 | ||
66 | /** | |
67 | * The local por t number t o which th is socket is connect ed. | |
68 | */ | |
69 | protec ted int lo calport; | |
70 | ||
71 | /** | |
72 | * Cre ates eithe r a stream or a data gram socke t. | |
73 | * | |
74 | * @pa ram s tream if {@code tr ue}, creat e a stream socket; | |
75 | * ot herwise, c reate a da tagram soc ket. | |
76 | * @ex ception I OException if an I/ O error oc curs while creating the | |
77 | * socket. | |
78 | */ | |
79 | protec ted abstra ct void cr eate(boole an stream) throws IO Exception; | |
80 | ||
81 | /** | |
82 | * Con nects this socket to the speci fied port on the nam ed host. | |
83 | * | |
84 | * @pa ram h ost the name of th e remote h ost. | |
85 | * @pa ram p ort the port numbe r. | |
86 | * @ex ception I OException if an I/ O error oc curs when connecting to the | |
87 | * remote ho st. | |
88 | */ | |
89 | protec ted abstra ct void co nnect(Stri ng host, i nt port) t hrows IOEx ception; | |
90 | ||
91 | /** | |
92 | * Con nects this socket to the speci fied port number on the specif ied host. | |
93 | * | |
94 | * @pa ram a ddress t he IP addr ess of the remote ho st. | |
95 | * @pa ram p ort t he port nu mber. | |
96 | * @ex ception I OException if an I/ O error oc curs when attempting a | |
97 | * connectio n. | |
98 | */ | |
99 | protec ted abstra ct void co nnect(Inet Address ad dress, int port) thr ows IOExce ption; | |
100 | ||
101 | /** | |
102 | * Con nects this socket to the speci fied port number on the specif ied host. | |
103 | * A t imeout of zero is in terpreted as an infi nite timeo ut. The co nnection | |
104 | * wil l then blo ck until e stablished or an err or occurs. | |
105 | * | |
106 | * @pa ram a ddress t he Socket address of the remot e host. | |
107 | * @pa ram ti meout the timeout v alue, in m illisecond s, or zero for no ti meout. | |
108 | * @ex ception I OException if an I/ O error oc curs when attempting a | |
109 | * connectio n. | |
110 | * @si nce 1.4 | |
111 | */ | |
112 | protec ted abstra ct void co nnect(Sock etAddress address, i nt timeout ) throws I OException ; | |
113 | ||
114 | /** | |
115 | * Bin ds this so cket to th e specifie d local IP address a nd port nu mber. | |
116 | * | |
117 | * @pa ram h ost an I P address that belon gs to a lo cal interf ace. | |
118 | * @pa ram p ort the port numbe r. | |
119 | * @ex ception I OException if an I/ O error oc curs when binding th is socket. | |
120 | */ | |
121 | protec ted abstra ct void bi nd(InetAdd ress host, int port) throws IO Exception; | |
122 | ||
123 | /** | |
124 | * Set s the maxi mum queue length for incoming connection indicatio ns | |
125 | * (a request to connect) to the {@c ode count} argument. If a | |
126 | * con nection in dication a rrives whe n the queu e is full, the | |
127 | * con nection is refused. | |
128 | * | |
129 | * @pa ram b acklog t he maximum length of the queue . | |
130 | * @ex ception I OException if an I/ O error oc curs when creating t he queue. | |
131 | */ | |
132 | protec ted abstra ct void li sten(int b acklog) th rows IOExc eption; | |
133 | ||
134 | /** | |
135 | * Acc epts a con nection. | |
136 | * | |
137 | * @pa ram s the acc epted conn ection. | |
138 | * @ex ception I OException if an I/ O error oc curs when accepting the | |
139 | * connectio n. | |
140 | */ | |
141 | protec ted abstra ct void ac cept(Socke tImpl s) t hrows IOEx ception; | |
142 | ||
143 | /** | |
144 | * Ret urns an in put stream for this socket. | |
145 | * | |
146 | * @re turn a stream fo r reading from this socket. | |
147 | * @ex ception I OException if an I/ O error oc curs when creating t he | |
148 | * input str eam. | |
149 | */ | |
150 | protec ted abstra ct InputSt ream getIn putStream( ) throws I OException ; | |
151 | ||
152 | /** | |
153 | * Ret urns an ou tput strea m for this socket. | |
154 | * | |
155 | * @re turn a n output s tream for writing to this sock et. | |
156 | * @ex ception I OException if an I/ O error oc curs when creating t he | |
157 | * output st ream. | |
158 | */ | |
159 | protec ted abstra ct OutputS tream getO utputStrea m() throws IOExcepti on; | |
160 | ||
161 | /** | |
162 | * Ret urns the n umber of b ytes that can be rea d from thi s socket | |
163 | * wit hout block ing. | |
164 | * | |
165 | * @re turn t he number of bytes t hat can be read from this sock et | |
166 | * w ithout blo cking. | |
167 | * @ex ception I OException if an I/ O error oc curs when determinin g the | |
168 | * number of bytes ava ilable. | |
169 | */ | |
170 | protec ted abstra ct int ava ilable() t hrows IOEx ception; | |
171 | ||
172 | /** | |
173 | * Clo ses this s ocket. | |
174 | * | |
175 | * @ex ception I OException if an I/ O error oc curs when closing th is socket. | |
176 | */ | |
177 | protec ted abstra ct void cl ose() thro ws IOExcep tion; | |
178 | ||
179 | /** | |
180 | * Pla ces the in put stream for this socket at "end of st ream". | |
181 | * Any data sent to this s ocket is a cknowledge d and then | |
182 | * sil ently disc arded. | |
183 | * | |
184 | * If you read f rom a sock et input s tream afte r invoking this meth od on the | |
185 | * soc ket, the s tream's {@ code avail able} meth od will re turn 0, an d its | |
186 | * {@c ode read} methods wi ll return {@code -1} (end of s tream). | |
187 | * | |
188 | * @ex ception IO Exception if an I/O error occu rs when sh utting dow n this | |
189 | * soc ket. | |
190 | * @se e java.net .Socket#sh utdownOutp ut() | |
191 | * @se e java.net .Socket#cl ose() | |
192 | * @se e java.net .Socket#se tSoLinger( boolean, i nt) | |
193 | * @si nce 1.3 | |
194 | */ | |
195 | protec ted void s hutdownInp ut() throw s IOExcept ion { | |
196 | thro w new IOEx ception("M ethod not implemente d!"); | |
197 | } | |
198 | ||
199 | /** | |
200 | * Dis ables the output str eam for th is socket. | |
201 | * For a TCP soc ket, any p reviously written da ta will be sent | |
202 | * fol lowed by T CP's norma l connecti on termina tion seque nce. | |
203 | * | |
204 | * If you write to a socke t output s tream afte r invoking | |
205 | * shu tdownOutpu t() on the socket, t he stream will throw | |
206 | * an IOExceptio n. | |
207 | * | |
208 | * @ex ception IO Exception if an I/O error occu rs when sh utting dow n this | |
209 | * soc ket. | |
210 | * @se e java.net .Socket#sh utdownInpu t() | |
211 | * @se e java.net .Socket#cl ose() | |
212 | * @se e java.net .Socket#se tSoLinger( boolean, i nt) | |
213 | * @si nce 1.3 | |
214 | */ | |
215 | protec ted void s hutdownOut put() thro ws IOExcep tion { | |
216 | thro w new IOEx ception("M ethod not implemente d!"); | |
217 | } | |
218 | ||
219 | /** | |
220 | * Ret urns the v alue of th is socket' s {@code f d} field. | |
221 | * | |
222 | * @re turn the value of t his socket 's {@code fd} field. | |
223 | * @se e java .net.Socke tImpl#fd | |
224 | */ | |
225 | protec ted FileDe scriptor g etFileDesc riptor() { | |
226 | re turn fd; | |
227 | } | |
228 | ||
229 | /** | |
230 | * Ret urns the v alue of th is socket' s {@code a ddress} fi eld. | |
231 | * | |
232 | * @re turn the value of t his socket 's {@code address} f ield. | |
233 | * @se e java .net.Socke tImpl#addr ess | |
234 | */ | |
235 | protec ted InetAd dress getI netAddress () { | |
236 | re turn addre ss; | |
237 | } | |
238 | ||
239 | /** | |
240 | * Ret urns the v alue of th is socket' s {@code p ort} field . | |
241 | * | |
242 | * @re turn the value of t his socket 's {@code port} fiel d. | |
243 | * @se e java .net.Socke tImpl#port | |
244 | */ | |
245 | protec ted int ge tPort() { | |
246 | re turn port; | |
247 | } | |
248 | ||
249 | /** | |
250 | * Ret urns wheth er or not this Socke tImpl supp orts sendi ng | |
251 | * urg ent data. By default , false is returned | |
252 | * unl ess the me thod is ov erridden i n a sub-cl ass | |
253 | * | |
254 | * @re turn true if urgent data supp orted | |
255 | * @se e java .net.Socke tImpl#addr ess | |
256 | * @si nce 1.4 | |
257 | */ | |
258 | protec ted boolea n supports UrgentData () { | |
259 | re turn false ; // must be overrid den in sub -class | |
260 | } | |
261 | ||
262 | /** | |
263 | * Sen d one byte of urgent data on t he socket. | |
264 | * The byte to b e sent is the low ei ght bits o f the para meter | |
265 | * @pa ram data T he byte of data to s end | |
266 | * @ex ception IO Exception if there i s an error | |
267 | * se nding the data. | |
268 | * @si nce 1.4 | |
269 | */ | |
270 | protec ted abstra ct void se ndUrgentDa ta (int da ta) throws IOExcepti on; | |
271 | ||
272 | /** | |
273 | * Ret urns the v alue of th is socket' s {@code l ocalport} field. | |
274 | * | |
275 | * @re turn the value of t his socket 's {@code localport} field. | |
276 | * @se e java .net.Socke tImpl#loca lport | |
277 | */ | |
278 | protec ted int ge tLocalPort () { | |
279 | re turn local port; | |
280 | } | |
281 | ||
282 | void s etSocket(S ocket soc) { | |
283 | th is.socket = soc; | |
284 | } | |
285 | ||
286 | Socket getSocket () { | |
287 | re turn socke t; | |
288 | } | |
289 | ||
290 | void s etServerSo cket(Serve rSocket so c) { | |
291 | th is.serverS ocket = so c; | |
292 | } | |
293 | ||
294 | Server Socket get ServerSock et() { | |
295 | re turn serve rSocket; | |
296 | } | |
297 | ||
298 | /** | |
299 | * Ret urns the a ddress and port of t his socket as a {@co de String} . | |
300 | * | |
301 | * @re turn a st ring repre sentation of this so cket. | |
302 | */ | |
303 | public String to String() { | |
304 | re turn "Sock et[addr=" + getInetA ddress() + | |
305 | ",port=" + getPort () + ",loc alport=" + getLocalP ort() + " ]"; | |
306 | } | |
307 | ||
308 | void r eset() thr ows IOExce ption { | |
309 | ad dress = nu ll; | |
310 | PORT ; | |
311 | local PORT
|
|
312 | } | |
313 | ||
314 | /** | |
315 | * Set s performa nce prefer ences for this socke t. | |
316 | * | |
317 | * <p> Sockets u se the TCP /IP protoc ol by defa ult. Some implement ations | |
318 | * may offer alt ernative p rotocols w hich have different performanc e | |
319 | * cha racteristi cs than TC P/IP. Thi s method a llows the applicatio n to | |
320 | * exp ress its o wn prefere nces as to how these tradeoffs should be made | |
321 | * whe n the impl ementation chooses f rom the av ailable pr otocols. | |
322 | * | |
323 | * <p> Performan ce prefere nces are d escribed b y three in tegers | |
324 | * who se values indicate t he relativ e importan ce of shor t connecti on time, | |
325 | * low latency, and high b andwidth. The absol ute values of the in tegers | |
326 | * are irrelevan t; in orde r to choos e a protoc ol the val ues are si mply | |
327 | * com pared, wit h larger v alues indi cating str onger pref erences. N egative | |
328 | * val ues repres ent a lowe r priority than posi tive value s. If the | |
329 | * app lication p refers sho rt connect ion time o ver both l ow latency and high | |
330 | * ban dwidth, fo r example, then it c ould invok e this met hod with t he values | |
331 | * {@c ode (1, 0, 0)}. If the applic ation pref ers high b andwidth a bove low | |
332 | * lat ency, and low latenc y above sh ort connec tion time, then it c ould | |
333 | * inv oke this m ethod with the value s {@code ( 0, 1, 2)}. | |
334 | * | |
335 | * By default, t his method does noth ing, unles s it is ov erridden i n a | |
336 | * a s ub-class. | |
337 | * | |
338 | * @pa ram conne ctionTime | |
339 | * An {@ code int} expressing the relat ive import ance of a short | |
340 | * conne ction time | |
341 | * | |
342 | * @pa ram laten cy | |
343 | * An {@ code int} expressing the relat ive import ance of lo w | |
344 | * laten cy | |
345 | * | |
346 | * @pa ram bandw idth | |
347 | * An {@ code int} expressing the relat ive import ance of hi gh | |
348 | * bandw idth | |
349 | * | |
350 | * @si nce 1.5 | |
351 | */ | |
352 | protec ted void s etPerforma ncePrefere nces(int c onnectionT ime, | |
353 | int late ncy, | |
354 | int band width) | |
355 | { | |
356 | /* Not imple mented yet */ | |
357 | } | |
358 | ||
359 | <T> vo id setOpti on(SocketO ption<T> n ame, T val ue) throws IOExcepti on { | |
360 | if (name == StandardSo cketOption s.SO_KEEPA LIVE) { | |
361 | setOptio n(SocketOp tions.SO_K EEPALIVE, value); | |
362 | } else if (n ame == Sta ndardSocke tOptions.S O_SNDBUF) { | |
363 | setOptio n(SocketOp tions.SO_S NDBUF, val ue); | |
364 | } else if (n ame == Sta ndardSocke tOptions.S O_RCVBUF) { | |
365 | setOptio n(SocketOp tions.SO_R CVBUF, val ue); | |
366 | } else if (n ame == Sta ndardSocke tOptions.S O_REUSEADD R) { | |
367 | setOptio n(SocketOp tions.SO_R EUSEADDR, value); | |
368 | } else if (n ame == Sta ndardSocke tOptions.S O_LINGER) { | |
369 | setOptio n(SocketOp tions.SO_L INGER, val ue); | |
370 | } else if (n ame == Sta ndardSocke tOptions.I P_TOS) { | |
371 | setOptio n(SocketOp tions.IP_T OS, value) ; | |
372 | } else if (n ame == Sta ndardSocke tOptions.T CP_NODELAY ) { | |
373 | setOptio n(SocketOp tions.TCP_ NODELAY, v alue); | |
374 | } else { | |
375 | throw ne w Unsuppor tedOperati onExceptio n("unsuppo rted optio n"); | |
376 | } | |
377 | } | |
378 | ||
379 | <T> T getOption( SocketOpti on<T> name ) throws I OException { | |
380 | if (name == StandardSo cketOption s.SO_KEEPA LIVE) { | |
381 | return ( T)getOptio n(SocketOp tions.SO_K EEPALIVE); | |
382 | } else if (n ame == Sta ndardSocke tOptions.S O_SNDBUF) { | |
383 | return ( T)getOptio n(SocketOp tions.SO_S NDBUF); | |
384 | } else if (n ame == Sta ndardSocke tOptions.S O_RCVBUF) { | |
385 | return ( T)getOptio n(SocketOp tions.SO_R CVBUF); | |
386 | } else if (n ame == Sta ndardSocke tOptions.S O_REUSEADD R) { | |
387 | return ( T)getOptio n(SocketOp tions.SO_R EUSEADDR); | |
388 | } else if (n ame == Sta ndardSocke tOptions.S O_LINGER) { | |
389 | return ( T)getOptio n(SocketOp tions.SO_L INGER); | |
390 | } else if (n ame == Sta ndardSocke tOptions.I P_TOS) { | |
391 | return ( T)getOptio n(SocketOp tions.IP_T OS); | |
392 | } else if (n ame == Sta ndardSocke tOptions.T CP_NODELAY ) { | |
393 | return ( T)getOptio n(SocketOp tions.TCP_ NODELAY); | |
394 | } else { | |
395 | throw ne w Unsuppor tedOperati onExceptio n("unsuppo rted optio n"); | |
396 | } | |
397 | } | |
398 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.