Agrega en un formulario el componente Microsoft Winsock control 6.0
crea un winsock llamado "Winsock1"
agrega un boton (command1) en caption q diga HOSTEAR, mete otro abajo (command2) llamado CONECTARSE alado ponele un textbox llamado text3
pone un timer llamado timer1
mas abajo pone un textbox gigante llamado Text1 y en la opcion Multiline ponele True
mas abajo pone un textbox llamado Text2 y alado un command buton llamado command3
apreta Inicio, panel de control Firewall de windows, Agregar Puerto (TCP) Puerto "77".
espero q te funcione
'CODIGO (Cliente)
Private Sub Command1_Click()
Winsock1.LocalPort = 77
Winsock1.Listen
End Sub
Public Function WinsockSend(pSock As Winsock, ByVal Data As String)
' send the data on the passed winsock
If pSock.State = sckConnected Then
' send the data and return true
pSock.SendData Data
DoEvents
WinsockSend = True
Else
' return false because we're not connected
WinsockSend = False
End If
End Function
Public Function WinsockGet(pSock As Winsock, ByVal Data As String)
' send the data on the passed winsock
If pSock.State = sckConnected Then
' send the data and return true
pSock.GetData Data
DoEvents
WinsockGet = True
If Not Data = vbNullString Then
Text1.Text = Text1.Text & Chr(13) + Chr(10) & Data
End If
Else
' return false because we're not connected
WinsockGet = False
End If
End Function
Private Sub Command3_Click()
blnRetVal = WinsockSend(Winsock1, Text2.Text)
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
blnRetVal = WinsockGet(Winsock1, strData)
End Sub
Private Sub Winsock1_Connect()
MsgBox "Connected"
End Sub
Private Sub Command2_Click()
Winsock1.RemoteHost = Text3.Text
Winsock1.RemotePort = 77
Winsock1.Connect
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, _
ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, _
ByVal HelpContext As Long, CancelDisplay As Boolean)
MsgBox "Error: " & Description
End Sub
Private Sub Winsock1_ConnectionRequest(ByVal RequestID As Long)
Winsock1.Close
Winsock1.Accept RequestID
End Sub