Is there any mechanism for broadcast messages for every client?

Hi, all
I just wanna to develop such a kind of chatting program. So I just build the communication structure for that. I want to use UDP protocol to send and recieve messages. As we know about that protocol, it does not need connection between server and client, so some packages will be lost. I just used only one DatagramSocket to recieve and send any messages back and forth. And I implemented the client using multithread technique. The problem is that when multiple client sent messages to server, how could server broadcast the specific message to all clients. I am very headache about that. I just used Vector to store diffrent address and port. And when a meesage arrived, I will firstly make ajustment about whether the address and port had been stored, if not, I will add, otherwise I will ignore it. So I think it will be terrible that if thousands of clients connected to the server, how big Vector will be. So I want to know whether the Net package or DatagramSocket provided some kind of mechanism about broadcast messages for every interested client. Thanks. Here is my code below:
ChattingServer.java
* Created on 2005-4-16
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
// A server that echoes datagrams
import java.net.*;
import java.io.*;
import java.util.*;
* @author Kevin
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
public class ChattingServer {
     static final int INPUT = 1066;
     private byte[] buf = new byte[1000];
     private DatagramPacket dp = new DatagramPacket(buf, buf.length);
     private DatagramSocket socket;
     private Vector addrVector, portVector;
     public ChattingServer() {
          try {
               System.out.println("Chatting Server Started......");
               socket = new DatagramSocket(INPUT);
               System.out.println("The status is: " + socket.getBroadcast());
               addrVector = new Vector();
               portVector = new Vector();
               socket.receive(dp);
               addrVector.addElement(dp.getAddress());
               portVector.addElement(new Integer(dp.getPort()));
               System.out.println("The original size of addrVector: " + addrVector.size());
               System.out.println("The original size of portVector: " + portVector.size());
               String first = Transfer.toString(dp);
               System.out.println(first);
               System.out.println("The info: " + dp.getAddress() + ": " + dp.getPort());
               DatagramPacket echo = Transfer.toDatagram(first, dp.getAddress(), dp.getPort());
               socket.send(echo);
               while(true) {
                    socket.receive(dp);
                    System.out.println("A message recieved and prepare for broadcasting.....");
                    for(int i = 0; i < addrVector.size(); i++){
                         if(!((((InetAddress)(addrVector.elementAt(i))).toString() == (dp.getAddress()).toString()) && (((Integer)portVector.elementAt(i)).toString() == (new Integer(dp.getPort())).toString()))) {
                              System.out.println("Before adding element");
                              System.out.println("(InetAddress)(addrVector.elementAt(i)).toString(): " + ((InetAddress)(addrVector.elementAt(i))).toString() + ", dp.getAddress().toString(): " + (dp.getAddress()).toString());
                              System.out.println("(Integer)portVector.elementAt(i).toString(): " + ((Integer)portVector.elementAt(i)).toString() + ", (new Integer(dp.getPort())).toString()" + (new Integer(dp.getPort())).toString());
                              addrVector.addElement(dp.getAddress());
                              portVector.addElement(new Integer(dp.getPort()));
                    String info = dp.getAddress() + ": " + dp.getPort();
                    String rcvd = info + ": " + Transfer.toString(dp);
                    System.out.println(rcvd);
                    System.out.println("The size of addrVector is: " + addrVector.size());
                    System.out.println("The size of portVector is: " + portVector.size());
                    String echoString = Transfer.toString(dp);
                    for(int i = 0; i < addrVector.size(); i++) {
                         InetAddress tempAddr = (InetAddress)addrVector.elementAt(i);
                         int tempPort = Integer.parseInt(portVector.elementAt(i).toString());
                         System.out.println("The port is: " + tempPort);
                         echo = Transfer.toDatagram(echoString, tempAddr, tempPort);
                         socket.send(echo);
          } catch(SocketException e) {
               System.err.println("Can't open socket");
               System.exit(1);
          } catch(IOException e) {
               System.err.println("Communication error");
               e.printStackTrace();
     public static void main(String[] args) {
          new ChattingServer();
ChattingClient.java
* Created on 2005-4-16
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
// Tests the ChattingServer by starting multiple clients, each of which sends datagrams.
import java.lang.Thread;
import java.net.*;
import java.io.*;
* @author Kevin
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
class Sender extends Thread {
     private DatagramSocket s;
     private InetAddress hostAddress;
     public Sender(DatagramSocket s) {
          this.s = s;
          try {
               hostAddress = InetAddress.getByName(null);
          } catch(UnknownHostException e) {
               System.err.println("Can not find host");
               System.exit(1);
          System.out.println(" Welcome ChattingDemo..........");
          System.out.println("Please input your name&#65306; ");
     public void run() {
          try {
               String strSent;
               BufferedReader rd = new BufferedReader(new InputStreamReader(System.in));
               String name = rd.readLine();
               while(true) {
                    System.out.print(name + ": ");
                    strSent = rd.readLine();
                    if(strSent == "END") break;
                    s.send(Transfer.toDatagram(strSent, hostAddress, ChattingServer.INPUT));
                    sleep(100);
               System.exit(1);
          } catch(IOException e) {
          } catch(InterruptedException e) {
public class ChattingClient extends Thread {
     private static DatagramSocket s, srv;
     private byte[] buf = new byte[1000];
     private DatagramPacket dp = new DatagramPacket(buf, buf.length);
     public ChattingClient(DatagramSocket s) {
          this.s = s;
     public void run() {
          try {
               while(true) {
                    s.receive(dp);
                    String rcvd = Transfer.toString(dp);
                    System.out.println(rcvd);
                    sleep(100);
          } catch(IOException e) {
               e.printStackTrace();
               System.exit(1);
          }catch(InterruptedException e) {
     public static void main(String[] args) {
          try {
               srv = new DatagramSocket();
          } catch(SocketException e) {
               System.err.println("Can not open socket");
               e.printStackTrace();
               System.exit(1);
          new ChattingClient(srv).start();
          new Sender(srv).start();
}

Hello Amir,
ACS used to tie the license to the MAC address of the machine but I believe Cisco removed that in version 5.1 or 5.2 as users were facing with issues if the MAC changed on a virtual machine. 
Other Cisco products, such as the ASA, Call Manger, and even ISE are a lot more restrictive when it comes to licensing. However, Cisco in general has many products that are licensed on the "honor system" where you are responsible for reporting and paying for everything that you are using. 
Also, I suppose Cisco could audit any companies out there and figure out what the company is using vs what it actually paid for :)
I hope this helps!
Thank you for rating helpful posts!

Similar Messages

  • Is there any mechanism where Oracle ESB can store messages

    Hello All,
    Is there any mechanism where Oracle ESB can store messages? like MQ does , Due to any reason if any compoenet goes down or Database goes down messages should not lost.
    But not sure if Oracle ESB in Oracle SOA Suite 10g has feature to persist the messages ?
    Waiting for reply.
    Thanks & Regards
    Kumar

    In 10g, ESB doesnot come with this builtin, you can use AQ/JMS to store the messages.
    Regards,
    Shanmu.

  • Is there any driver Konica Minolta Di2510f for Snow leopard?

    Is there any driver Konica Minolta Di2510f for Snow leopard?

    You have a very old printer. The lastest driver I saw was one for Tiger. Whether it works in Snow Leopard?
    Are you able to physically attach the printer to your Mac (unknown), because being very old, it may not even be able to plug into it. Most modern Macs require USB.
    The link I found, though I don't think the software would be all that useful.
    http://onyxftp.mykonicaminolta.com/download/SearchResults.aspx?productid=323
    Message was edited by: roam

  • Is there any limitation of memory uses for apps in iPad2 or iPad3 ?

    Hi,
       Is there any limitation of memory uses for apps in ipad2 or ipad3 .For example an application can use 10% or 20% of available memory , is there anything like that or the apps can use the total available memory or like 90% of it ?
    I want to know about the memory distribution to the apps in ios .
    Would anyone suggest a right way ?
    Thanks

    iOS manages all memory. You should test your app in Instruments to be sure it is playing nice.
    See Advanced Memory Management Programming Guide

  • How to configure Broadcast messaging for IC Webclient profile

    Dear all,
    How to configure Broadcast messaging for IC Webclient profile. what are the prerequisites for it?
    We are not using EP interface for IC Webclient, then where can I find broadcast messaging URL in SAP CRM system.
    I have checked for the relevant BSP application, but could not find.
    Please help me to configure the scenario successfully, your help will be highly appreciated.
    Best regards,
    Raghu ram

    Hi raghu
    In CRM Broad cast messaging application is CRM _BM,
    Go to easy access u2013 go to favourites u2013 select add other objects - select BSP Applications- then select CRM_BM Application.
    Select that BSP application and test it u2026
    `
    Regards,
    Narsimha

  • Is there any best practice or standard for database object naming ?

    Hi
    Thank you for reading my post
    is there any standard or best practice for databse objects naming ?
    for example how should we name columns of a table ? should it be like TOTAL_VOTE or TOTALVOTE and many other items.
    Thanks

    what does oracle suggest as a naming schema for tables , fields , views. indexes , tablespaces , ... If you look at the data dictionary you will see that not even Oracle keeps rigidly to any specific standard, although there are tendencies :)
    "The nice thing about standards is that there are so many of them to choose from."      
    -- Andrew Tannenbaum
    Cheers, APC

  • Is there any "Tesseract OCR API" available for "IOS SDK 7.0" ??

    I want to make an application in IOS SDK 7.0 with Xcode 5 that required "Tesseract OCR API". So, Is there any "Tesseract OCR API" available for "IOS SDK 7.0" ? if any, please post the download link.
    Thanks

    I went on with the instructions and it worked properly with whitebackground image with black colored texts and it provide garbage value results with colored images. However when I try to run it on XCode 5.1 it shows "Caanot initialize an object of type 'Tesseract *' with rvalue 'BOOL' in the  "
    (id)initWithDataPath:(NSString *)dataPath
                  language:(NSString *)language
             ocrEngineMode:(NSString *)mode
           configFilenames:(NSArray*)configFilenames
                 variables:(NSDictionary*)variables
    setOnlyNonDebugParams:(BOOL)setOnlyNonDebugParams" method.
    And when I try to modify it then it display many linker errors.

  • I have recently updated to ios5 and when restoring apps etc it says my backup needs a password, i password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?

    i have recently updated to ios5 and when restoring apps etc it says my backup needs a password, a password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?
    i'm desperately in need as EVERYTHING my life revolvesaround is on there

    i have recently updated to ios5 and when restoring apps etc it says my backup needs a password, a password that i cannot for the life of me remember...is there any 'forgotten password' option available for the backup please?
    i'm desperately in need as EVERYTHING my life revolvesaround is on there

  • Are there any presets in iPhoto '11 for print quality?

    Are there any presets in iPhoto '11 for print quality?

    No.  Just use the greatest number of pixels for your photo available.  Other quality settings would be in the printer window, i.e. color settings, etc.
    OT

  • Is there any way to use a For Each Loop for each property of an User Defined Type?

    Is there any way to use a For Each Loop for each property of an User Defined Type? That would be very handy!
    Jorge Barbi Martins ([email protected])

    Alas, no, not in VBA.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Is there any way to lock just for settings?

    When I let my son 5 to play my iPad.  He sometimes click Settings and play around and caused change the settings.  Is there any possible to lock just for settings.  When you click the settings and it must have passcode to change anything in settings. 

    Settings>General>Restrictions>Enable Restrictions. Take a look at this.
    iOS: Understanding Restrictions (Parental Controls) - Support - Apple
    You could move the settings app into a folder on another screen that your son might not be apt to look in. Put in a folder on a home screen that he doesn't use. Keep his stuff accessible on one of the first home screens and encourage him to not stray from that screen.

  • Is there any voice recognition security software for mac

    is there any voice recognition security software for mac

    The problem is that there are probably few dry cleaners running Macs. It would be a big commitment for a developer to enter that market. As a potential user, I'm sure you would like it. From a developer standpoint, I would need 50 such dry cleaners ready to buy at $1000 each just to even consider it. I have some time to develop this year. Should I go after 200 million potential customers, a tiny fraction of whom might spend $5-10 apiece, or those 50 dry cleaners. I know that all of those 200 million people are running the correct operating system for my software. How many dry cleaners have Macs and $1000 to spare? I could go cheaper but then I would need more dry cleaners. Why wouldn't they just use some cloud based service instead?

  • Are there any standard Idocs or Bapis for posting the data into transaction

    Hi,
    Are there any standard Idocs or Bapis for posting the data into transactions ME42N and IK11?
    Thank You.

    Thank you.
    Any idea of the other one?

  • Is there any way to Authorization Management for Material Components?

    Hello every body
       Is there any way to Authorization Management for Material Components? 
       For example  i want to create , delete , modify  Material Components,how i can Authorization Management ?
       Enhancement or IMG or other ways?
                                                                                    thanks

    Alas, no, not in VBA.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Is there any way to raise alerts for stock outages in inventory

    Is there any way to raise alerts for stock outages in inventory

    You can use the Check Material Shortages attribute in the Org items under Inventory tab. Oracle will trigger shortage alert notifucations for the checked items. This works in the conjuntion with the Shortage Parameters defined at the Inv ORg level (these parameters are nothing but what business wants to consider as a shortage in WIP and OM). You can notify the cmp planner/buyer , assy planner/job creator..

Maybe you are looking for