88 * ST_NOT_CONNECTED = socket not connected
89 * ST_CONNECTED = socket connected
90 * ST_CONNECTED_NO_IMPL = socket connected but not at impl level
91 */
92 static final int ST_NOT_CONNECTED = 0;
93 static final int ST_CONNECTED = 1;
94 static final int ST_CONNECTED_NO_IMPL = 2;
95
96 int connectState = ST_NOT_CONNECTED;
97
98 /*
99 * Connected address & port
100 */
101 InetAddress connectedAddress = null;
102 int connectedPort = -1;
103
104 /**
105 * Connects this socket to a remote socket address (IP address + port number).
106 * Binds socket if not already bound.
107 * <p>
108 * @param addr The remote address.
109 * @param port The remote port
110 * @throws SocketException if binding the socket fails.
111 */
112 private synchronized void connectInternal(InetAddress address, int port) throws SocketException {
113 if (port < 0 || port > 0xFFFF) {
114 throw new IllegalArgumentException("connect: " + port);
115 }
116 if (address == null) {
117 throw new IllegalArgumentException("connect: null address");
118 }
119 checkAddress (address, "connect");
120 if (isClosed())
121 return;
122 SecurityManager security = System.getSecurityManager();
123 if (security != null) {
124 if (address.isMulticastAddress()) {
125 security.checkMulticast(address);
126 } else {
127 security.checkConnect(address.getHostAddress(), port);
128 security.checkAccept(address.getHostAddress(), port);
|
88 * ST_NOT_CONNECTED = socket not connected
89 * ST_CONNECTED = socket connected
90 * ST_CONNECTED_NO_IMPL = socket connected but not at impl level
91 */
92 static final int ST_NOT_CONNECTED = 0;
93 static final int ST_CONNECTED = 1;
94 static final int ST_CONNECTED_NO_IMPL = 2;
95
96 int connectState = ST_NOT_CONNECTED;
97
98 /*
99 * Connected address & port
100 */
101 InetAddress connectedAddress = null;
102 int connectedPort = -1;
103
104 /**
105 * Connects this socket to a remote socket address (IP address + port number).
106 * Binds socket if not already bound.
107 * <p>
108 * @param address The remote address.
109 * @param port The remote port
110 * @throws SocketException if binding the socket fails.
111 */
112 private synchronized void connectInternal(InetAddress address, int port) throws SocketException {
113 if (port < 0 || port > 0xFFFF) {
114 throw new IllegalArgumentException("connect: " + port);
115 }
116 if (address == null) {
117 throw new IllegalArgumentException("connect: null address");
118 }
119 checkAddress (address, "connect");
120 if (isClosed())
121 return;
122 SecurityManager security = System.getSecurityManager();
123 if (security != null) {
124 if (address.isMulticastAddress()) {
125 security.checkMulticast(address);
126 } else {
127 security.checkConnect(address.getHostAddress(), port);
128 security.checkAccept(address.getHostAddress(), port);
|