Delen via


RemoteAgent.CreatePacketStream Method

Creates a connection to the device agent to exchange data.

Namespace:  Microsoft.SmartDevice.Connectivity
Assembly:  Microsoft.SmartDevice.Connectivity (in Microsoft.SmartDevice.Connectivity.dll)

Syntax

'Declaration
Public Function CreatePacketStream ( _
    serviceId As ObjectId _
) As DevicePacketStream
'Usage
Dim instance As RemoteAgent 
Dim serviceId As ObjectId 
Dim returnValue As DevicePacketStream 

returnValue = instance.CreatePacketStream(serviceId)
public DevicePacketStream CreatePacketStream(
    ObjectId serviceId
)
public:
DevicePacketStream^ CreatePacketStream(
    ObjectId^ serviceId
)
public function CreatePacketStream(
    serviceId : ObjectId
) : DevicePacketStream

Parameters

Return Value

Type: Microsoft.SmartDevice.Connectivity.DevicePacketStream
A DevicePacketStream object that can transfer data between the device agent and the development computer.

Exceptions

Exception Condition
SmartDeviceException

Occurs if a COM exception is thrown by underlying COM components.

DeviceNotConnectedException

Occurs if a device is not connected.

Remarks

There must be a device-side agent ready to accept a connection on the same service ID. The device-side agent is deployed when Start is called. A device agent can accept multiple stream connections on different service IDs.

Examples

' Open communication channel with device agent. 
Dim ps As DevicePacketStream = ra.CreatePacketStream( _
    New ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"))

' Create and write a packet of data. 
Dim packet As Packet
packet = New Packet()
Dim i As Integer 
For i = 0 To 3
    packet.WriteInt32(i)
Next i
packet.WriteString("Hello Smart Device")
ps.Write(packet)
// Open communication channel with device agent.
DevicePacketStream ps = ra.CreatePacketStream(
    new ObjectId("2FAD740C-B5D3-4ad0-BE23-5682503584BF"));

// Create and write a packet of data.
Packet packet;
packet = new Packet();
for (int i = 0; i < 4; i +) packet.WriteInt32(i);
packet.WriteString("Hello Smart Device");
ps.Write(packet);

.NET Framework Security

See Also

Reference

RemoteAgent Class

RemoteAgent Members

Microsoft.SmartDevice.Connectivity Namespace