Comments (4)
Hello,
I'm using the code below on the OnDataReceived
event to disconnect the client:
// Disconnect client
e.Client.Dispose();
from easytcp.
I like to use that on OnConnect to automatically disconnect if the connected clients are more then a preset int
internal static readonly int maxClients = 1;
from easytcp.
Hi,
Just call .Dispose() on the client like @cristianszpisjak suggested.
Here is an example for the OnConnect event:
using EasyTcp3;
using EasyTcp3.ServerUtils;
var server = new EasyTcpServer().Start(8080);
server.OnConnect += (sender, client) =>
{
if (((EasyTcpServer)sender).ConnectedClientsCount > 10)
client.Dispose(); // Disconnect client
};
Note that the OnConnect() function will return true client side, because the client is accepted(the event is fired) and then disconnected(.Dispose()
).
from easytcp.
thx worked great
from easytcp.
Related Issues (20)
- Feature request: configurable PrefixLengthProtocol HOT 1
- Create documentation HOT 3
- Refactor EasyTcp.Tests
- PrefixLengthProtocol filling Message.Data with null/empty data HOT 4
- No "Send"-Method avaiable. :( HOT 2
- Can Connect local, but not from outside network HOT 2
- PrefixLengthProtocol in v4.x is is not compatible with itself depending on max message size HOT 1
- Exceed 64K limit packet size? HOT 3
- Release v4 HOT 4
- Received packets send by `SendLargeArray` contains invalid data/bytes HOT 2
- Send an object to the server HOT 4
- System.Security.Cryptography.CryptographicException: m_safeCertContext is an invalid handle. HOT 1
- Nuget? HOT 2
- Client disconnecting issue HOT 3
- I get SocketException on server Start() HOT 2
- in EasyAction event handler method, can not call form controll?? HOT 1
- set time out for client to disconnect from server HOT 1
- System.NullReferenceException: 'Object reference not set to an instance of an object HOT 10
- SSL Server gets crashed by NonSSL client connecting and closing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easytcp.