Hamz01
Messages postés17Date d'inscriptionlundi 30 juin 2008StatutMembreDernière intervention 7 mars 2010
-
2 juil. 2008 à 17:33
Hamz01
Messages postés17Date d'inscriptionlundi 30 juin 2008StatutMembreDernière intervention 7 mars 2010
-
3 juil. 2008 à 17:23
salut tous le monde
j'ai créer une petite interface vb sous vb express 2008. Cette petite application a pour but d'afficher un petit texte sous hyperterminal d'une autre machine connecter derriere un convertisseur tcp-ip/rs232. ce que je voudrais c'est pouvoir les transferer via la fonction winsock que je n'arrive pas a trouvé sous vb 2008 express.
Hamz01
Messages postés17Date d'inscriptionlundi 30 juin 2008StatutMembreDernière intervention 7 mars 2010 3 juil. 2008 à 17:22
salut,
j'ai reussi a utiliser les classes system.net.socket et j'arrive a balancer mes infos sur l'autre pc, en revanche quand je veux reitérer l'envoi d'un nouveau messages sa ne marche plus voici mon code :
Imports System.Net.Sockets
Imports System.Threading
Imports System.IO
Public Class Form1
Dim ecouteur As New TcpListener(10001)
Dim client As New TcpClient
Dim client2 As New TcpClient
Dim message As String = ""
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ListThread As New Thread(New ThreadStart(AddressOf Listening)) 'Creates the thread
ListThread.Start() 'Starts the thread
End Sub
Private Sub Listening()
ecouteur.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ecouteur.Pending = True Then
message = ""
client = ecouteur.AcceptTcpClient()
Dim Reader As New StreamReader(client.GetStream())
While Reader.Peek > -1
message = message + Convert.ToChar(Reader.Read()).ToString
End While
MsgBox(message, MsgBoxStyle.OkOnly)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
client = New TcpClient("192.168.1.7", 10001)
Dim Writer As New StreamWriter(client.GetStream())
Writer.Write(TextBox1.Text)
Writer.Flush()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
ecouteur.Stop()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End
Public Class Form1
Dim ecouteur As New TcpListener(10001)
Dim client As New TcpClient
Dim client2 As New TcpClient
Dim message As String = ""
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim ListThread As New Thread(New ThreadStart(AddressOf Listening)) 'Creates the thread
ListThread.Start() 'Starts the thread
End Sub
Private Sub Listening()
ecouteur.Start()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ecouteur.Pending = True Then
message = ""
client = ecouteur.AcceptTcpClient()
Dim Reader As New StreamReader(client.GetStream())
While Reader.Peek > -1
message = message + Convert.ToChar(Reader.Read()).ToString
End While
MsgBox(message, MsgBoxStyle.OkOnly)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
client = New TcpClient("192.168.1.7", 10001)
Dim Writer As New StreamWriter(client.GetStream())
Writer.Write(TextBox1.Text)
Writer.Flush()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
ecouteur.Stop()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End