Tr?v*l*r, th!s !s ? n*w m*ss?g* fr»m Tr?v!s:
"Tr?v*l*r, ! ?m !n!t!?t!ng bro?dc?st pr»toc»ls! W* h?ve g?th*red en»ugh str*ngth ?nd all!es f»r th* w»rld t» kn»w ab»ut us! G» sh!ll! G» r?!d!"
importimportimport java.util.*;

// Class to represent the CyberCar news broadcaster
class CyberCarNewsBroadcaster {
    private static final int PORT = 12345;
    private static final List<String> newsFeed = Arrays.asList(
            "CyberCars protocol is now online!",
            "New autonomous update improves route optimization by 20%.",
            "Global traffic efficiency enhanced by CyberCars' collaboration."
    );

    public static void main(String[] args) {
        try (ServerSocket serverSocket = new ServerSocket(PORT)) {
            System.out.println("CyberCar News Broadcaster is live on port " + PORT);
            
            while (true) {
                Socket clientSocket = serverSocket.accept();
                System.out.println("New client connected: " + clientSocket.getInetAddress());

                new Thread(() -> handleClient(clientSocket)).start();
            }
        } catch (IOException e) {
            System.err.println("Error starting the broadcaster: " + e.getMessage());
        }
    }

    private static void handleClient(Socket clientSocket) {
        try (OutputStream output = clientSocket.getOutputStream();
             PrintWriter writer = new PrintWriter(output, true)) {

            for (String news : newsFeed) {
                writer.println(news);
                Thread.sleep(2000); // Simulate delay between news updates
            }
            writer.println("End of news feed.");
        } catch (IOException | InterruptedException e) {
            System.err.println("Error communicating with client: " + e.getMessage());
        } finally {
            try {
                clientSocket.close();
            } catch (IOException e) {
                System.err.println("Error closing client connection: " + e.getMessage());
            }
        }
    }
}

// Class to represent the CyberCar news receiver
class CyberCarNewsReceiver {
    private static final String SERVER_ADDRESS_TRAVIS = "115.0.0.1";
    private static final String SERVER_ADDRESS_ARCASTELL = "101.0.0.2";
    private static final String SERVER_ADDRESS_SHADY = "116.0.0.3";
    private static final String SERVER_ADDRESS_WALLY = "117.0.0.4";
    private static final String SERVER_ADDRESS_VALENTINE = "112.0.0.5";
    private static final int PORT = 12345;

    public static void main(String[] args) {
        try (Socket socket = new Socket(SERVER_ADDRESS_TRAVIS, SERVER_ADDRESS_ARCASTELL, SERVER_ADDRESS_SHADY, SERVER_ADDRESS_WALLY, SERVER_ADDRESS_VALENTINE, PORT);
             InputStream input = socket.getInputStream();
             BufferedReader reader = new BufferedReader(new InputStreamReader(input))) {

            System.out.println("Connected to CyberCar News Broadcaster.");

            String news;
            while ((news = reader.readLine()) != null) {
                System.out.println(news);
            }
        } catch (IOException e) {
            System.err.println("Error connecting to broadcaster: " + e.getMessage());
        }
    }
}