Implementation import java. Class D IP addresses are in the range The address Here is a sample output of the above program: We have used the multicast host IP address as There are 3 members in the group: Ironman, CaptainAmerica, and Groot. Start bi phone chat three terminals first before sending the message, otherwise messages which are sent before starting the terminal are lost since there is richmond chat lines facility of buffer incorporated to store the messages.
We need two thre in this application. One for accepting the user input using the java. Scanner class and the other for reading the messages sent from other clients.
Hence I have separated the thread which does the reading work into ReadThreadclass. For leaving the group, any of the user can type in Exit to terminate the session.
2. create the chat server program
The above program is executed on a single machine. Socket programming is meant for distributed programming. The same piece of code snippet when present on different machines which have Java installed can satisfy that requirement. live chat with girls
This is just the bare bones service logic. The project would be even more fascinating if the front-end is developed. Additional points:. Related Articles. ReadThread socket,group,port. String message. DatagramPacket buffer,buffer.
String buffer, 0 ,datagram. Recommended Articles. Article Contributed By :. Easy Normal Medium Hard Expert. Most popular in GBlog.
Most visited in Java. Writing code in comment?