use of java.net.Socket in project hazelcast by hazelcast.
the class InitConnectionTask method bindSocket.
private void bindSocket(SocketChannel socketChannel) throws IOException {
InetAddress inetAddress = getInetAddress();
Socket socket = socketChannel.socket();
if (connectionManager.useAnyOutboundPort()) {
SocketAddress socketAddress = new InetSocketAddress(inetAddress, 0);
socket.bind(socketAddress);
} else {
IOException ex = null;
int retryCount = connectionManager.getOutboundPortCount() * 2;
for (int i = 0; i < retryCount; i++) {
int port = connectionManager.acquireOutboundPort();
SocketAddress socketAddress = new InetSocketAddress(inetAddress, port);
try {
socket.bind(socketAddress);
return;
} catch (IOException e) {
ex = e;
logger.finest("Could not bind port[ " + port + "]: " + e.getMessage());
}
}
throw ex;
}
}
use of java.net.Socket in project gitblit by gitblit.
the class LaunchWithUITestConfig method shutdownGitBlitServer.
private static void shutdownGitBlitServer(int shutdownPort) {
try {
Socket s = new Socket(InetAddress.getByName("127.0.0.1"), shutdownPort);
OutputStream out = s.getOutputStream();
System.out.println("Sending Shutdown Request to " + Constants.NAME);
out.write("\r\n".getBytes());
out.flush();
s.close();
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
use of java.net.Socket in project libstreaming by fyhertz.
the class RtspClient method tryConnection.
private void tryConnection() throws IOException {
mCSeq = 0;
mSocket = new Socket(mParameters.host, mParameters.port);
mBufferedReader = new BufferedReader(new InputStreamReader(mSocket.getInputStream()));
mOutputStream = new BufferedOutputStream(mSocket.getOutputStream());
sendRequestAnnounce();
sendRequestSetup();
sendRequestRecord();
}
use of java.net.Socket in project fqrouter by fqrouter.
the class DNSConnection method getInetAddress.
/**
* NOTE: Result != null unless connection is closed.
**
* @since 2.0
*/
public final InetAddress getInetAddress() {
Socket socket;
InetAddress address = null;
if ((socket = this.socket) != null)
address = socket.getInetAddress();
return address;
}
use of java.net.Socket in project fqrouter by fqrouter.
the class DNSConnection method openIncoming.
/**
* NOTE: old connection should be closed. Wait for any incoming
* connection and accept it. If listening is not active or if
* SecurityException is caught then SocketException is thrown. If
* waiting fails then InterruptedIOException is thrown. Must be
* synchronized outside.
**
* @since 3.0
*/
public void openIncoming() throws IOException {
ServerSocket curListener;
if ((curListener = listener) != null) {
try {
Socket socket = curListener.accept();
BufferedInputStream in = new BufferedInputStream(socket.getInputStream(), DNSMsgHeader.UDP_PACKET_LEN);
this.out = socket.getOutputStream();
this.in = in;
this.msgBytes = null;
this.socket = socket;
return;
} catch (SecurityException e) {
}
}
throw new SocketException(curListener == null ? "Not listening" : "SecurityException: accept()");
}
Aggregations