
LinkDone event
Fires when devP2P links with remote devP2P instance.
Syntax
- C#
- C++
- VB.NET
delegate void devP2P.LinkDoneEvent(IntPtr Handle, string address, int port, int errorno);
The LinkDone(Handle,address,port) syntax has these parts:
The LinkDone(Handle,address,port) syntax has these parts:
Handle | Reference to the devP2P instance. |
address | IP address of remote peer. |
port | Port of remote peer. |
void LinkDone(CP2P *p2p, char *address, int port, Errors error);
The LinkDone(p2p,address,port) syntax has these parts:
The LinkDone(p2p,address,port) syntax has these parts:
p2p | Pointer to devP2P instance that fired the event. |
address | Pointer to allocated memory with the IP address of remote peer. |
port | Port of remote peer. |
Delegate Sub P2P_LinkDoneEvent(ByVal Handle As IntPtr, ByVal address As String, ByVal port As Integer, ByVal errorno As Integer)
The LinkDone(Handle,address,port) syntax has these parts:
The LinkDone(Handle,address,port) syntax has these parts:
Handle | Reference to the devP2P instance. |
address | IP address of remote peer. |
port | Port of remote peer. |
Remarks
After remote devP2P peer is located (through Search method), and Link method was called, devP2P will try to connect to remote devP2P peer. After successful link, this event will be fired. Now you can call, for example, StartForward to begin forwarding ports between local and remote side, can send text messages etc.Note that this event can be fired if you called Start method, and doing nothing, if remote peer initiated Link method call to you, from his side.
To obtain connection type (UDP/TCP), you can use ConnectionType property.
To use this event, you should implement function by yourself in the code (based on function declaration), and set devP2P.Events.LinkDone structure member to point to your function.
Code sample
- C++
void p2p_LinkDone(devP2Plib::CP2P *p2p, char *address, int port, devP2Plib::Errors error)
{
if (!error)
printf("%s] Connected to %s (%d)\r\n", p2p->MyName, address, port);
else
printf("%s] Connection failed with error %s (%d)\r\n", p2p->MyName, p2p->ErrorText(error), error);
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.LinkDone = p2p_LinkDone;
/* ... */
}
{
if (!error)
printf("%s] Connected to %s (%d)\r\n", p2p->MyName, address, port);
else
printf("%s] Connection failed with error %s (%d)\r\n", p2p->MyName, p2p->ErrorText(error), error);
}
int main(int argc, char **argv)
{
/* ... */
devP2Plib::CP2P *p1 = devP2Plib::CP2P::Create();
/* ... */
p1->Events.LinkDone = p2p_LinkDone;
/* ... */
}
Platforms
WindowsMac OSX
Linux
BSD