
SendData method
Sends byte array message to remote peer.
Type
Integer.Syntax
- C#
- C++
- VB.NET
int devP2P.SendData(IntPtr Handle, int chanid, string data, int len, bool reliable);
The SendData(Handle,chanid,data,len,reliable) syntax has these parts:
The SendData(Handle,chanid,data,len,reliable) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Integer that specifies channel index. |
data | String with data. |
len | Total number of bytes to send. |
reliable | Determines if packet should be delivered in reliable way. Defaults to true. |
Return value | 0 (ErrorNone) if success, otherwise negative value from Errors enumeration. |
int SendData(int chanid, char *data, int len, bool reliable = true);
The SendData(chanid,data,len,reliable) syntax has these parts:
The SendData(chanid,data,len,reliable) syntax has these parts:
chanid | Integer that specifies channel index. |
data | Pointer to allocated memory where data is stored. |
len | Length of data buffer to send. |
reliable | Determines if packet should be delivered in reliable way. Defaults to true. |
Return value | 0 (ErrorNone) if success, otherwise negative value from Errors enumeration. |
Function P2P_SendData(ByVal Handle As IntPtr, ByVal chanid As Integer, ByVal data As String, ByVal len As Integer, ByVal reliable As Boolean) As Integer
The SendData(Handle,chanid,data,len,reliable) syntax has these parts:
The SendData(Handle,chanid,data,len,reliable) syntax has these parts:
Handle | Reference to the devP2P instance. |
chanid | Integer that specifies channel index. |
data | String with data. |
len | Total number of bytes to send. |
reliable | Determines if packet should be delivered in reliable way. Defaults to true. |
Return value | 0 (ErrorNone) if success, otherwise negative value from Errors enumeration. |
Remarks
SendData will send byte array to remote peer. On peer's side, DataReceived event will fire when byte array arrives. You can use this method only after connection with remote peer is established, of course.You should select one of 1024 available channels to send this message. Make sure that channel is not already used by file transfer, or channel forwarding. You can send more than one message through the channel, so usually you can pick channel 0 for messages of any kind.
If you did not specify reliable method, it is possible packet never reaches the destination. This makes sense for information that is not important and possibly will be resent (such as some status information you want to provide to remote side).
You will not get any confirmation that your message is delivered.
Platforms
WindowsMac OSX
Linux
BSD