investigando sobre el control Winsock vi q casi todos los ej los hacian con un "chat" a si q empese haciendo eso... y lo fui mejorando... y esto es lo q me quedo
en un form:
un winsock
dos textbox
dos timer
un commandbutton
Dim texto As String
Dim ip As String
Dim port As Long
Private Sub Form_Load()
ip = "127.0.1"
port = 142
Timer2.Interval = 1
Timer2.Enabled = False
Timer1.Interval = 1750
End Sub
Private Sub Command3_Click()
Dim enviar As String
On Error Resume Next
If Winsock1.State = 7 Then
enviar = Text2.Text
Winsock1.SendData enviar
texto = Text1.Text + "#" + enviar
Text1.Text = texto
Text2.Text = ""
Else
MsgBox "No estas conectado", vbCritical, "Error"
End If
End Sub
Private Sub Text1_Change()
Text1.Text = texto
End Sub
Private Sub Text2_Change()
If Text2.Text = "" Then
Command3.Enabled = False
Else
Command3.Enabled = True
End If
End Sub
Private Sub Timer1_Timer()
On Error Resume Next
If Winsock1.State <> 7 Then
Winsock1.Close
Winsock1.Connect ip, port
Timer2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
On Error Resume Next
If Winsock1.State = 7 Then
Winsock1.SendData "Se conecto"
Timer2.Enabled = False
End If
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Beep
Dim datos As String
Winsock1.GetData datos
texto = Text1.Text + "//" + datos
Text1.Text = texto
End Sub
en otro form:
un winsock
dos textbox
un commandbutton
Dim texto As String
Private Sub Command3_Click()
Dim enviar As String
On Error Resume Next
If Winsock1.State = 7 Then
enviar = Text2.Text
Winsock1.SendData enviar
texto = Text1.Text + "#" + enviar
Text1.Text = texto
Text2.Text = ""
Else
MsgBox "No estas conectado", vbCritical, "Error"
Winsock1.Close
Winsock1.Listen
End If
End Sub
Private Sub Form_Load()
Winsock1.Listen
End Sub
Private Sub Text1_Change()
Text1.Text = texto
End Sub
Private Sub Text2_Change()
If Text2.Text = "" Then
Command3.Enabled = False
Else
Command3.Enabled = True
End If
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
Winsock1.Close
Winsock1.Accept requestID
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim datos As String
Winsock1.GetData datos
Beep
texto = Text1.Text + "//" + datos
Text1.Text = texto
End Sub
bueno... espero q a algun novato le sirva para aprender algo... y q les alla gustado...
lo q les queria preguntar... como hacer para q cuando se envie el texto se ponga en otra linea... xq si no queda todo en una sola y es muy feo... (por eso puse los separadores # y //)