Winsock sous vb 2008 express

Résolu
Hamz01 Messages postés 17 Date d'inscription lundi 30 juin 2008 Statut Membre Dernière intervention 7 mars 2010 - 2 juil. 2008 à 17:33
Hamz01 Messages postés 17 Date d'inscription lundi 30 juin 2008 Statut Membre Derniè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.

4 réponses

radcur Messages postés 282 Date d'inscription lundi 29 septembre 2003 Statut Membre Dernière intervention 15 août 2012 2
2 juil. 2008 à 19:01
salut

les winsock n'existent plus en .Net 2005 et +

des classes existent dans system.net.socket  (imports system.net.socket)
3
Hamz01 Messages postés 17 Date d'inscription lundi 30 juin 2008 Statut Membre Dernière intervention 7 mars 2010
3 juil. 2008 à 09:22
re :

merci pour ta rep mais dans ce cas comment je peux ljavascript:Insert_Emoticon('/imgs2/smile_wink.gif');es utiliser dans le cadre de mon application
0
Hamz01 Messages postés 17 Date d'inscription lundi 30 juin 2008 Statut Membre Derniè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

End Sub

End Class
0
Hamz01 Messages postés 17 Date d'inscription lundi 30 juin 2008 Statut Membre Dernière intervention 7 mars 2010
3 juil. 2008 à 17:23
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

End Sub

End Class
0
Rejoignez-nous