' Collection of code snippets by Arne Vajhøj ' posted to eksperten.dk, usenet and other places (2002-now) Imports System Imports System.IO Imports System.Net Imports System.Net.Sockets Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Namespace DefaultNamespace Public Class MainForm Inherits Form Private send As Button Private client As TcpClient Private rdr As StreamReader Private wrt As StreamWriter Public Sub New() InitializeComponent client = New TcpClient("localhost", 1234) rdr = New StreamReader(client.GetStream) wrt = New StreamWriter(client.GetStream) call (New Thread(AddressOf Reader)).Start End Sub _ Public Shared Sub Main(ByVal args As String()) Application.Run(New MainForm) End Sub Private Sub InitializeComponent() send = New Button SuspendLayout send.Location = New Point(50, 50) send.Size = New Size(100, 50) send.Text = "Send" AddHandler send.Click, AddressOf SendClick ClientSize = New Size(200, 150) Controls.Add(send) Text = "Client" ResumeLayout(False) End Sub Sub SendClick(ByVal sender As Object, ByVal e As System.EventArgs) wrt.WriteLine("Godaw do") wrt.Flush End Sub Private Sub Reader() Dim line As String line = rdr.ReadLine While Not (line Is Nothing) MessageBox.Show(line) line = rdr.ReadLine End While End Sub End Class End Namespace