()
| 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 |
no test coverage detected