ServerFramework | distributed Java game server framework that can be
kandi X-RAY | ServerFramework Summary
kandi X-RAY | ServerFramework Summary
A distributed Java game server framework that can be used as a global server or rolling server, with several utilities and game clients
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handler for receiving messages .
- Login action .
- Checks if there is a winner in a match
- Perform a force operation .
- Push out client offline message
- Handles a frame read .
- Send a net message to a player
- Scans the specified package and returns a set of classes .
- create a new user
- Convert the message to binary data .
ServerFramework Key Features
ServerFramework Examples and Code Snippets
Community Discussions
Trending Discussions on ServerFramework
QUESTION
I want to avoid the TIME_WAIT state when closing a TCP socket (I am aware of the pros and cons of circumventing TIME_WAIT).
I am using Windows and WinSock2/.Net sockets and am having great difficulty getting the SO_LINGER
socket option to work as described in the documentation.
My test code with most of the error checking removed for brevity is:
...ANSWER
Answered 2019-Oct-22 at 19:30You can't really avoid TIME_WAIT
when your app is the one closing the TCP connection first (TIME_WAIT
does not happen when the peer closes the connection first). No amount of SO_LINGER
settings will change that fact, other than performing an abortive socket closure (ie sending a RST
packet). It is simply part of how TCP works (look at the TCP state diagram). SO_LINGER
simply controls how long closesocket()
waits before actually closing an active connection.
The only way to prevent the socket from entering the TIME_WAIT
state is to set the l_linger
duration to 0, and don't call shutdown(SD_SEND)
or shutdown(SD_BOTH)
at all (calling shutdown(SD_RECEIVE)
is OK). This is documented behavior:
The closesocket call will only block until all data has been delivered to the peer or the timeout expires. If the connection is reset because the timeout expires, then the socket will not go into TIME_WAIT state. If all data is sent within the timeout period, then the socket can go into TIME_WAIT state.
If the l_onoff member of the linger structure is nonzero and the l_linger member is a zero timeout interval on a blocking socket, then a call to closesocket will reset the connection. The socket will not go to the TIME_WAIT state.
The real problem with your code (aside from the lack of error handling) is that your client is bind()
'ing a client socket before connect()
'ing it to a server. Typically, you should not bind()
a client socket at all, you should let the OS choose an appropriate binding for you. However, if you must bind()
a client socket, you will likely need to enable the SO_REUSEADDR
option on that socket to avoid being blocked when a previous connection boudn to the same local IP/Port is still in TIME_WAIT
state and you are trying to connect()
in a short amount of time after the previous closesocket()
.
See How to avoid TIME_WAIT state after closesocket() ? for more details. Also, the document you linked to in your question also explains ways to avoid TIME_WAIT
without resorting to messing with SO_LINGER
.
QUESTION
Our application has a feature to actively connect to the customers' internal factory network and send a message when inspection events occur. The customer enters the IP address and port number of their machine and application into our software.
I'm using a TClientSocket in blocking mode and have provided callback functions for the OnConnect
and OnError
events. Assuming the abovementioned feature has been activated, when the application starts I call the following code in a separate thread:
ANSWER
Answered 2017-Nov-08 at 16:43A) The cause of the resource leak was a programming error. When the OnError
event occurs, Socket.Close()
should be called to release low-level resources associated with the socket.
B) The memory leak does not show up in the standard Working Set
memory use of the process. Open handles belonging to your process need to be monitored which is possible with GetProcessHandleCount
. See this answer in Delphi which was tested and works well. This answer in C++ was not tested but the answer is accepted so should work. Of course, you should be able to use GetProcessHandleCount
directly in C++.
C) After much research, I must conclude that just like a normal memory leak, you cannot just ask Windows to "clean up" after you! The handle resource has been leaked by your application and you must find and fix the cause (see A and B above).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ServerFramework
You can use ServerFramework 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 ServerFramework 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