61
62 /* indicates a close is pending on the file descriptor */
63 protected boolean closePending = false;
64
65 /* indicates connection reset state */
66 private int CONNECTION_NOT_RESET = 0;
67 private int CONNECTION_RESET_PENDING = 1;
68 private int CONNECTION_RESET = 2;
69 private int resetState;
70 private final Object resetLock = new Object();
71
72 /* whether this Socket is a stream (TCP) socket or not (UDP)
73 */
74 protected boolean stream;
75
76 /**
77 * Load net library into runtime.
78 */
79 static {
80 java.security.AccessController.doPrivileged(
81 new sun.security.action.LoadLibraryAction("net"));
82 }
83
84 /**
85 * Creates a socket with a boolean that specifies whether this
86 * is a stream socket (true) or an unconnected UDP socket (false).
87 */
88 protected synchronized void create(boolean stream) throws IOException {
89 this.stream = stream;
90 if (!stream) {
91 ResourceManager.beforeUdpCreate();
92 // only create the fd after we know we will be able to create the socket
93 fd = new FileDescriptor();
94 try {
95 socketCreate(false);
96 } catch (IOException ioe) {
97 ResourceManager.afterUdpClose();
98 fd = null;
99 throw ioe;
100 }
101 } else {
102 fd = new FileDescriptor();
|
61
62 /* indicates a close is pending on the file descriptor */
63 protected boolean closePending = false;
64
65 /* indicates connection reset state */
66 private int CONNECTION_NOT_RESET = 0;
67 private int CONNECTION_RESET_PENDING = 1;
68 private int CONNECTION_RESET = 2;
69 private int resetState;
70 private final Object resetLock = new Object();
71
72 /* whether this Socket is a stream (TCP) socket or not (UDP)
73 */
74 protected boolean stream;
75
76 /**
77 * Load net library into runtime.
78 */
79 static {
80 java.security.AccessController.doPrivileged(
81 new java.security.PrivilegedAction<Void>() {
82 public Void run() {
83 System.loadLibrary("net");
84 return null;
85 }
86 });
87 }
88
89 /**
90 * Creates a socket with a boolean that specifies whether this
91 * is a stream socket (true) or an unconnected UDP socket (false).
92 */
93 protected synchronized void create(boolean stream) throws IOException {
94 this.stream = stream;
95 if (!stream) {
96 ResourceManager.beforeUdpCreate();
97 // only create the fd after we know we will be able to create the socket
98 fd = new FileDescriptor();
99 try {
100 socketCreate(false);
101 } catch (IOException ioe) {
102 ResourceManager.afterUdpClose();
103 fd = null;
104 throw ioe;
105 }
106 } else {
107 fd = new FileDescriptor();
|