SocketTools .NET Edition

InternetServer.OnAccept Event

Occurs when a client attempts to establish a connection with the server.

[Visual Basic]
Public Event OnAccept As OnAcceptEventHandler
[C#]
public event OnAcceptEventHandler OnAccept;

Event Data

The event handler receives an argument of type InternetServer.AcceptEventArgs containing data related to this event. The following InternetServer.AcceptEventArgs properties provide information specific to this event.

Property Description
ClientAddress Gets a value that specifies the Internet address of the current client session.
ClientPort Gets a value that specifies the port number used by the current client session.
Handle Gets a value that specifies the socket handle for the listening server.

Remarks

The OnAccept event occurs when a client attempts to connect to the local system. A connection is not actually established until it has been accepted by the server.

The ClientAddress or ClientHost properties may be used to determine the Internet address and host name of the remote host that is establishing the connection. To prevent the client from completing the connection, call the Reject method.

After the client connection has been established and the worker thread for that client session has started, the OnConnect event will fire.

User interface controls can only be accessed from the UI thread that created them, and attempting to update a control from another thread can result in the program becoming non-responsive or terminating abnormally. Because this event is generated in the context of the server thread, not the thread that created the class instance, you cannot directly modify a control from within this event handler. Instead, you must create a delegate and use the Invoke method to marshal invocations to the associated UI thread. For more information, refer to the documentation for the control.

See Also

InternetServer Class | SocketTools Namespace