Ich habe folgendes problem ich möchte zwei programme schreiben eins das sendet und eins das bei einem bestimten satz der gesendet wir eine aktion ausfürt bzw ich möchte das gesendete als string weiter in Program 2 verwenden
Program 1
Imports System.Net.Sockets, System.Threading, System.IO
Public Class Form1
Dim client As tcpclient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = "" Then
MsgBox("bitte text eingeben")
Else
client = New TcpClient(TextBox1.Text, 8000)
Dim writer As New StreamWriter(client.GetStream())
writer.Write(TextBox2.Text)
TextBox2.Clear()
writer.Flush()
End If
End Sub
End Class
und programm 2
Imports System.Net.Sockets, System.Threading, System.IO
Dim listener As New TcpListener(8000)
Dim client As TcpClient
Dim shutdownCommand As String
Form1_load
listener.Start()
Dim listthread As New Thread(New ThreadStart(AddressOf listening))
listthread.Start()
Private Sub Tmrlistener_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmrlistener.Tick
If listener.Pending = True Then
shutdownCommand = ""
client = listener.AcceptTcpClient
Dim reader As New StreamReader(client.GetStream())
While Reader.Peek > -1
shutdownCommand = shutdownCommand + Convert.ToChar(reader.Read()).ToString
End While
MsgBox(shutdownCommand)
End If
End Sub
End Class
Ich ghlaube das das problem an programm zwei lieg und er die daten nicht empfangen möchte
bitte um Hilfe
Program 1
Imports System.Net.Sockets, System.Threading, System.IO
Public Class Form1
Dim client As tcpclient
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox2.Text = "" Then
MsgBox("bitte text eingeben")
Else
client = New TcpClient(TextBox1.Text, 8000)
Dim writer As New StreamWriter(client.GetStream())
writer.Write(TextBox2.Text)
TextBox2.Clear()
writer.Flush()
End If
End Sub
End Class
und programm 2
Imports System.Net.Sockets, System.Threading, System.IO
Dim listener As New TcpListener(8000)
Dim client As TcpClient
Dim shutdownCommand As String
Form1_load
listener.Start()
Dim listthread As New Thread(New ThreadStart(AddressOf listening))
listthread.Start()
Private Sub Tmrlistener_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmrlistener.Tick
If listener.Pending = True Then
shutdownCommand = ""
client = listener.AcceptTcpClient
Dim reader As New StreamReader(client.GetStream())
While Reader.Peek > -1
shutdownCommand = shutdownCommand + Convert.ToChar(reader.Read()).ToString
End While
MsgBox(shutdownCommand)
End If
End Sub
End Class
Ich ghlaube das das problem an programm zwei lieg und er die daten nicht empfangen möchte
bitte um Hilfe