See Also

Udp Class  | Udp Members

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Languages PowerTCP SSL Sockets for .NET

BufferSize Property

Dart.PowerTCP.SslSockets Namespace > Udp Class : BufferSize Property

Gets and sets the size of the system receive buffer.

[Visual Basic]
<DescriptionAttribute("Gets and Sets the size of the system receive buffer.")> <CategoryAttribute("Socket Options")> <DefaultValueAttribute()> Public Property BufferSize As Integer
[C#]
[DescriptionAttribute("Gets and Sets the size of the system receive buffer.")] [CategoryAttribute("Socket Options")] [DefaultValueAttribute()] public int BufferSize {get; set;}
[C++]
[DescriptionAttribute("Gets and Sets the size of the system receive buffer.")] [CategoryAttribute("Socket Options")] [DefaultValueAttribute()] public: __property int get_BufferSize(); public: __property void set_BufferSize(    int value );
[C++/CLI]
[DescriptionAttribute("Gets and Sets the size of the system receive buffer.")] [CategoryAttribute("Socket Options")] [DefaultValueAttribute()] public: property int BufferSize {    int get();    void set (int value); }

Return Type

Size of the system receive buffer in bytes. The default is 8192.

Remarks

This property sets the size of the system receive buffer.

Example

The following example demonstrates creating a UDP echo server application which listens for datagrams and echoes them back to the sender.

[Visual Basic] 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
   ' Listen for datagrams on port 7.
   Udp1.Open(7)

   ' Begin an asynchronous Receive
   Dim buffer(Udp1.BufferSize) As Byte
   Udp1.BeginReceive(buffer)
End Sub

Private Sub Udp1_EndReceive(ByVal sender As Object, ByVal e As DatagramEventArgs) Handles Udp1.EndReceive

   ' Check for an Exception
   If e.Exception is Nothing Then
      ' Echo the data back using the Datagram object passed into the event.
      ' Datagram.Buffer = data received from client
      ' Datagram.RemoteEndPoint = address/port of client.
      Udp1.Send(e.Datagram.Buffer, e.Datagram.RemoteEndPoint)
   End If

   ' Start receiving next
   Dim buffer(Udp1.BufferSize) As Byte
   Udp1.BeginReceive(buffer)

End Sub

[C#] 


private void StartServer()
{            
  
// Listen for datagrams on port 7.
  
udp1.Open(7);

  
// Begin an asynchronous Receive
  
byte[] buffer = new byte[udp1.BufferSize];
  udp1.BeginReceive(buffer);
}

private void udp1_EndReceive(object sender, DatagramEventArgs e)
{
  
// Check for an exception
  
if(e.Exception == null)
  {
     
// Echo the data back using the Datagram object passed into the event.
     
// Datagram.Buffer = data received from client
     
// Datagram.RemoteEndPoint = address/port of client.
     
Datagram d = udp1.Send(e.Datagram.Buffer, e.Datagram.RemoteEndPoint);
  }        
  
// Start receiving next
  
byte[] buffer = new byte[udp1.BufferSize];
  udp1.BeginReceive(buffer);
}
                

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Udp Class  | Udp Members


Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.