MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / doConnect

Method doConnect

samples/JGroups/src/RouterStub.java:151–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

149 }
150
151 public synchronized void doConnect() throws Exception {
152 if(!isConnected()) {
153 try {
154 sock=new Socket();
155 sock.bind(new InetSocketAddress(bind_addr, 0));
156 sock.setSoTimeout(sock_read_timeout);
157 sock.setSoLinger(true, 2);
158 sock.setTcpNoDelay(tcp_nodelay);
159 sock.setKeepAlive(true);
160 Util.connect(sock, new InetSocketAddress(router_host, router_port), sock_conn_timeout);
161 output=new DataOutputStream(sock.getOutputStream());
162 input=new DataInputStream(sock.getInputStream());
163 connectionStateChanged(ConnectionStatus.CONNECTION_ESTABLISHED);
164 }
165 catch(Exception e) {
166 Util.close(sock);
167 Util.close(input);
168 Util.close(output);
169 connectionStateChanged(ConnectionStatus.CONNECTION_BROKEN);
170 throw new Exception("Could not connect to " + getGossipRouterAddress() , e);
171 }
172 }
173 }
174
175 /**
176 * Checks whether the connection is open

Callers 1

connectMethod · 0.95

Calls 8

isConnectedMethod · 0.95
bindMethod · 0.45
setTcpNoDelayMethod · 0.45
connectMethod · 0.45
getInputStreamMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected