public int getUDPPort() { return udpSocket.getLocalPort(); } }
public int getPort() { return this.socket.getLocalPort(); }
public static void main(String[] args) throws SocketException { ArrayList<DatagramSocket> a = new ArrayList<DatagramSocket>(); for(int i = 0 ; i < 10;i++){ DatagramSocket d = new DatagramSocket(0); a.add(d); System.out.println(d.getLocalPort()); } }
public static void main(String[] args) throws SocketException { ArrayList<DatagramSocket> a = new ArrayList<DatagramSocket>(); for(int i = 0 ; i < 10;i++){ DatagramSocket d = new DatagramSocket(0); a.add(d); System.out.println(d.getLocalPort()); } }
public TcpUdpBridgeServer(String remoteTcpHost, String remoteUdpHost, int remoteTcpPort, int remoteUdpPort) { this.remoteTcpHost = remoteTcpHost; this.remoteUdpHost = remoteUdpHost; this.remoteTcpPort = remoteTcpPort; this.remoteUdpPort = remoteUdpPort; try { serverTcpSocket = new ServerSocket(remoteTcpPort); localUdpSocket = new DatagramSocket(0); localUdpPort = localUdpSocket.getLocalPort(); LOGGER.fine("UDP: " + localUdpSocket.getLocalPort()); } catch (IOException e) { LOGGER.log(Level.WARNING, "exception", e); } startBridge(); }
public TcpUdpBridgeClient(String remoteTcpHost, String remoteUdpHost, int remoteTcpPort, int remoteUdpPort) { this.remoteTcpHost = remoteTcpHost; this.remoteUdpHost = remoteUdpHost; this.remoteTcpPort = remoteTcpPort; this.remoteUdpPort = remoteUdpPort; try { localTcpSocket = new Socket(remoteTcpHost, remoteTcpPort); localUdpSocket = new DatagramSocket(0); localUdpPort = localUdpSocket.getLocalPort(); LOGGER.fine("UDP: " + localUdpSocket.getLocalPort()); } catch (IOException e) { LOGGER.log(Level.WARNING, "exception", e); } startBridge(); }
protected PhysicalAddress getPhysicalAddress() { return sock != null ? new IpAddress(bind_addr, sock.getLocalPort()) : null; }
@Override public int getPort() { return datagramChannel == null ? 0 : datagramChannel.socket().getLocalPort(); }
public int getLocalPort() { return serverSocket == null ? 0 : serverSocket.getLocalPort(); }
public int getPort() { return channel.socket().getLocalPort(); }
/** * Returns the {@code SocketAddress} this socket is bound to, or null for an unbound socket. */ public SocketAddress getLocalSocketAddress() { if (!isBound()) { return null; } return new InetSocketAddress(getLocalAddress(), getLocalPort()); }
MessageHandler(InetAddress bind_interface) throws Exception { mcast_sock = new MulticastSocket(mcast_port); mcast_sock.setInterface(bind_interface); mcast_sock.setTimeToLive(ttl); mcast_sock.joinGroup(mcast_addr); sock = new DatagramSocket(0, bind_interface); local_addr = sock.getLocalAddress(); local_port = sock.getLocalPort(); }
public static synchronized short getNextMulticastPort(InetAddress bind_addr) throws Exception { short port = mcast_port; try { DatagramSocket sock = Util.createDatagramSocket(socket_factory, "jgroups.temp.resourcemgr.mcast_sock", bind_addr, port); port = (short) sock.getLocalPort(); socket_factory.close(sock); return port; } finally { mcast_port = (short) (port + 1); } }
public ImageTransmitter(DatagramSocket socket, InetAddress remoteHost, int remotePort, Rectangle area) { try { robot = new Robot(); maxI = (int) Math.ceil(area.getWidth() / tileWidth); maxJ = (int) Math.ceil(area.getHeight() / tileWidth); tiles = new int[maxI][maxJ][tileWidth * tileWidth]; this.area = area; this.socket = socket; localHost = socket.getLocalAddress(); localPort = socket.getLocalPort(); this.remoteHost = remoteHost; this.remotePort = remotePort; this.encoder = new DefaultEncoder(); transmit = true; } catch (AWTException e) { LOGGER.log(Level.WARNING, "exception", e); } }
@Override public void run() { try { //System.out.println("Listening for ECHO: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort()); while (true) { DatagramPacket packet = new DatagramPacket(new byte[8], 8); socket.receive(packet); System.out.println("ECHO Packet Received in: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort() + " From: " + packet.getAddress().getHostAddress() + ":" + packet.getPort()); for (DatagramListener listener : listeners) { listener.datagramReceived(packet); } packet.setAddress(packet.getAddress()); packet.setPort(packet.getPort()); if (!Arrays.equals(packet.getData(), password)) for (int i = 0; i < 3; i++) socket.send(packet); } } catch (IOException ioe) { if (enabled) { } } }
protected CommandChannel createCommandChannel() throws IOException { SocketAddress localAddress = createLocalAddress(); channel = DatagramChannel.open(); channel = connect(channel, targetAddress); DatagramSocket socket = channel.socket(); bind(socket, localAddress); if (port == 0) { port = socket.getLocalPort(); } return createCommandDatagramChannel(); }
@Override public void run() { try { LOGGER.fine("Listening for ECHO: " + socket.getLocalAddress().getHostAddress() + ":" + socket.getLocalPort()); while (true) {
if (TRACE) trace("kryonet", this + " received UDP: RegisterUDP"); if (DEBUG) { debug("kryonet", "Port " + udp.datagramChannel.socket().getLocalPort() + "/UDP connected to: " + udp.connectedAddress);
/*** * Returns the port number of the open socket on the local host used * for the connection. If you call this method when the client socket * is not open, a NullPointerException is thrown. * * @return The port number of the open socket on the local host used * for the connection. ***/ public int getLocalPort() { return _socket_.getLocalPort(); }
connection.sendTCP(new RegisterUDP()); if (DEBUG) debug("kryonet", "Port " + udp.datagramChannel.socket().getLocalPort() + "/UDP connected to: " + fromAddress); connection.notifyConnected(); continue;