Back to product page

ForwardOpen event


Fires when port forwarding is open.

Type

Boolean.

Syntax

  • C#
  • C++
  • VB.NET
delegate bool devP2P.ForwardOpenEvent(IntPtr Handle, int forwardid, int forwardtype, string localaddress, int localport, string remoteaddress, int remoteport);
The ForwardOpen(Handle,forwid,forwardtype,localaddress,localport,remoteaddress,remoteport) syntax has these parts:
HandleReference to the devP2P instance.
forwidForwarding channel index (0-31).
forwardtypeForwardTypes value, type of the forward.
localaddressLocal address that is used for forwarding.
localportLocal port that is used for forwarding.
remoteaddressRemote address that is used for forwarding.
remoteportRemote port that is used for forwarding.
Return valueReturn true if you accept the forwarding. If you return False, it will be cancelled.

bool ForwardOpen(CP2P *p2p, int forwid, ForwardTypes type, char *localaddress, int localport, char *remoteaddress, int remoteport);
The ForwardOpen(p2p,forwid,type,localaddress,localport,remoteaddress,remoteport) syntax has these parts:
p2pPointer to devP2P instance that fired the event.
forwidForwarding channel index (0-31).
typeForwardTypes value, type of the forward.
localaddressLocal address that is used for forwarding.
localportLocal port that is used for forwarding.
remoteaddressRemote address that is used for forwarding.
remoteportRemote port that is used for forwarding.
Return valueReturn true if you accept the forwarding. If you return False, it will be cancelled.

Delegate Function P2P_ForwardOpenEvent(ByVal Handle As IntPtr, ByVal forwardid As Integer, ByVal type As Integer, ByVal localaddress As String, ByVal localport As Integer, ByVal remoteaddress As String, ByVal remoteport As Integer) As Boolean
The ForwardOpen(handle,forwid,forwardtype,localaddress,localport,remoteaddress,remoteport) syntax has these parts:
handleReference to the devP2P instance.
forwidForwarding channel index (0-31).
forwardtypeForwardTypes value, type of the forward.
localaddressLocal address that is used for forwarding.
localportLocal port that is used for forwarding.
remoteaddressRemote address that is used for forwarding.
remoteportRemote port that is used for forwarding.
Return valueReturn true if you accept the forwarding. If you return False, it will be cancelled.

Remarks

ForwardOpen event fires when either local or remote peer has requested certain port to be forwarded to remote side. For most types both localaddress/port and remoteaddress/port must be set, and forwarding is made fixed->fixed ports. In such cases all arguments have real values. For SOCKS and HTTP forwards, remoteaddress is not known since it depends on user's request, so final information about the forward will be known in UserConnected event.

You can use GetForward method to obtain information about forwarding with specified forwid index. Forwarding does not use any channels yet - as users are connecting, they will be taking free channels, and releasing them when they disconnect.

One forwarding can accept many users at once. For each user that connects to this forwarding, UserConnected event will fire so you can track users and deny access based on your set of rules.

To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.ForwardOpen structure member to point to your function.

Code sample

  • C++

Platforms

Windows
Mac OSX
Linux
BSD