73 |
System.loadLibrary("javanet"); |
System.loadLibrary("javanet"); |
74 |
} |
} |
75 |
} |
} |
76 |
|
|
77 |
/** |
/** |
78 |
* Option id for the IP_TTL (time to live) value. |
* Option id for the IP_TTL (time to live) value. |
79 |
*/ |
*/ |
82 |
/** |
/** |
83 |
* This is the actual underlying file descriptor |
* This is the actual underlying file descriptor |
84 |
*/ |
*/ |
85 |
protected int native_fd = -1; |
int native_fd = -1; |
86 |
|
|
87 |
/** |
/** |
88 |
* Lock object to serialize threads wanting to receive |
* Lock object to serialize threads wanting to receive |
101 |
{ |
{ |
102 |
} |
} |
103 |
|
|
104 |
|
protected void finalize() throws Throwable |
105 |
|
{ |
106 |
|
synchronized (this) |
107 |
|
{ |
108 |
|
if (native_fd != -1) |
109 |
|
close(); |
110 |
|
} |
111 |
|
super.finalize(); |
112 |
|
} |
113 |
|
|
114 |
public int getNativeFD() |
public int getNativeFD() |
115 |
{ |
{ |
116 |
return native_fd; |
return native_fd; |
258 |
*/ |
*/ |
259 |
protected synchronized byte getTTL() throws IOException |
protected synchronized byte getTTL() throws IOException |
260 |
{ |
{ |
261 |
Object obj = getOption(IP_TTL); |
return (byte) getTimeToLive(); |
|
|
|
|
if (!(obj instanceof Integer)) |
|
|
throw new IOException("Internal Error"); |
|
|
|
|
|
return(((Integer)obj).byteValue()); |
|
262 |
} |
} |
263 |
|
|
264 |
/** |
/** |
272 |
*/ |
*/ |
273 |
protected synchronized void setTTL(byte ttl) throws IOException |
protected synchronized void setTTL(byte ttl) throws IOException |
274 |
{ |
{ |
275 |
if (ttl > 0) |
setTimeToLive(((int) ttl) & 0xFF); |
|
setOption(IP_TTL, new Integer(ttl)); |
|
|
else |
|
|
setOption(IP_TTL, new Integer(ttl + 256)); |
|
276 |
} |
} |
277 |
|
|
278 |
/** |
/** |