RTC Forums
November 24, 2024, 01:48:31 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Reject a specific HTTP connection?  (Read 4248 times)
craigism
RTC Expired
*
Posts: 5


« on: October 19, 2013, 09:07:37 PM »

I know that I can Accept a connection and then respond with a HTTP 403.  I also know that if I do not Accept a connection it will propagate through all rtcDataProviders and finally fail. 

How do I simply Reject a connection for a specific IP or MAC address?  I do not want all my other rtcDataProviders to try to respond.

I tried server.disconnect but that shuts the server.  I want to shut / block the connection or session.

Thanks.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: October 19, 2013, 09:18:12 PM »

To stop a connection from propagating through all DataProviders, call "Sender.Disconnect" from the OnClientConnect, OnConnecting or OnConnect event (Sender is the TRtcConnection parameter passed to the event) on the RtcHttpServer component. Calling Disconnect on the Sender:TRtcConnection from inside the event does not shut the Server, it only closes that single connection.

If you wanted to shut the Server, you would call StopListen or StopListenNow on the main RtcHttpServer component.

By the way ...

In order to obtain the IP address and Port of the connecting Client, the Server socket has to accept the connection. Only after the connection was accepted, you get a socket through which you can obtain the IP address and Port number of the Client. Before a connection was accepted, you only know that there is a connection waiting, but have no information about the Client.

Also, note that a connection closed by the Server will result in the Port used by that connection to remain unusable for about 2 minutes after the connection was closed. This is done by the TCP/IP stack, to ensure that any late packets sent through that (now closed) connection get discarded and do not end up in any newly open connection. As a side-effect, Server closing a lot of connections in a short time can end up with all its Ports occupied and being unable to accept any new connections, until some of the Ports become available again.

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.024 seconds with 17 queries.