ChernoChat | Cherno Chat project , as well as code | Socket library
kandi X-RAY | ChernoChat Summary
kandi X-RAY | ChernoChat Summary
All of the code for the Cherno Chat project, as well as the code for the individual episodes.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create the GUI
- Send a byte array to the server
- Close the connection
- Sends a message
- Start listening for events
- Write a message to the console
- Receive a message from the network
- Start listening to server
- Runs the server
- Manage the clients
- Disconnect a client
- Process a datagram packet
- Open a datagram socket
- Command line parser
- Main entry point
- Create a new client window
ChernoChat Key Features
ChernoChat Examples and Code Snippets
Community Discussions
Trending Discussions on ChernoChat
QUESTION
There are two classes Client
and ChatWindow
, client has DatagramSocket
, InetAddress
and port fields along with methods for sending, receiving, and closing the socket. To close a socket I use an anonymous thread "socketCLOSE"
Client class
...ANSWER
Answered 2021-Feb-24 at 14:08I can reproduce the problem with JDK 14, but not with JDK 15 or newer.
This seems plausible, as JDK-8235674, JEP 373: Reimplement the Legacy DatagramSocket API indicates that the implementation has been rewritten for JDK 15. The report even says “The implementation also has several concurrency issues (e.g., with asynchronous close) that require an overhaul to address properly.”
However, you can get rid of the problem with JDK 14 too; just remove the synchronized
. Nothing in the documentation says that synchronization was required to call close()
and when I removed it, my testcase worked as intended.
When you want to coordinate the multithreaded access to the socket of your application, you should use a different lock object than the socket instance itself.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ChernoChat
You can use ChernoChat like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the ChernoChat component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page