aboutsummaryrefslogtreecommitdiffhomepage
path: root/host.c
diff options
context:
space:
mode:
authoreihrul <eihrul>2010-05-14 18:20:20 +0000
committereihrul <eihrul>2010-05-14 18:20:20 +0000
commitc5189c090fc47503790bcb994232629897d61d7c (patch)
tree487dda62fc80a435388837781e140a4aab78dc6b /host.c
parentc4138503f9986e9afe032476daf033bd2d95b4d8 (diff)
downloadenet-c5189c090fc47503790bcb994232629897d61d7c.tar.gz
enet-c5189c090fc47503790bcb994232629897d61d7c.zip
added enet_host_channel_limit
Diffstat (limited to 'host.c')
-rw-r--r--host.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/host.c b/host.c
index 8d07e80..9edceb2 100644
--- a/host.c
+++ b/host.c
@@ -66,6 +66,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, enet_uint32 inc
if (address != NULL)
host -> address = * address;
+ host -> channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT;
host -> incomingBandwidth = incomingBandwidth;
host -> outgoingBandwidth = outgoingBandwidth;
host -> bandwidthThrottleEpoch = 0;
@@ -208,6 +209,22 @@ enet_host_connect (ENetHost * host, const ENetAddress * address, size_t channelC
return currentPeer;
}
+/** Limits the maximum allowed channels of future incoming connections.
+ @param host host to limit
+ @param channelLimit the maximum number of channels allowed; if 0, then this is equivalent to ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT
+*/
+void
+enet_host_channel_limit (ENetHost * host, size_t channelLimit)
+{
+ if (! channelLimit || channelLimit > ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT)
+ channelLimit = ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT;
+ else
+ if (channelLimit < ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT)
+ channelLimit = ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT;
+
+ host -> channelLimit = channelLimit;
+}
+
/** Queues a packet to be sent to all peers associated with the host.
@param host host on which to broadcast the packet
@param channelID channel on which to broadcast