AmenO123
Usuario (Argentina)

Hola, bienvenidos a mi Post, hoy les mostraré como hacer un chat cliente/servidor. Empezemos: Requisitos: Visual Basic 6.0 (Verción Full) Paciencia Comprensión Tener un poco de idea ----------------------------------------------------------------------------- Form1: Servidor Form2: Cliente .. Abrir Visual Basic 6.0 Seleccionar EXE Estandar Agregar al Form1: 3 TextBox 4 CommandButton 1 Winsock 4 Label Preguntas Frecuentes: ¿Cómo agrego un Winsock? Apretar Ctrl + T, buscar Microsoft Winsock 6.0, activar, Aceptar. ------------------------------------------------------------ Masomenos lo tienen que dejar así, el Frame no es importante: Donde yo escribí "By AmenO" pueden poner "By ...." Deben seguir el orden de creacion de cada uno, sino el programa haría cualquier cosa. Propiedades de cada objeto: TextBox1: Multiline = True ScrollBar = 2- Vertical -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Codigo: Private Sub Label4_Click() Label4.Caption = Winsock1.LocalIP End Sub Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "*** Peticion numero " & requestID & vbCrLf Text1.SelStart = Len(Text1.Text) Winsock1.Close Winsock1.Accept requestID Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "*** Conexion aceptada, listo para interactuar." & vbCrLf Text1.SelStart = Len(Text1.Text) End Sub Private Sub Command3_Click() Winsock1.Close Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "*** Conexion cerrada por el usuario." & vbCrLf Text1.SelStart = Len(Text1.Text) End Sub Private Sub Winsock1_Close() Winsock1.Close Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "*** Conexion cerrada por el Cliente." & vbCrLf Text1.SelStart = Len(Text1.Text) End Sub Private Sub Command1_Click() Winsock1.SendData Text2.Text & vbCrLf Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "Servidor >" & Text2.Text & vbCrLf Text1.SelStart = Len(Text1.Text) Text2.Text = "" End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim Buffer As String Winsock1.GetData Buffer Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "Cliente >" & Buffer Text1.SelStart = Len(Text1.Text) 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) Winsock1.Close MsgBox "Error numero " & Number & ": " & Description, vbCritical End Sub -*----*---*----*---*---*--*-*-*-*-*-*-*-*-*--*-*-*-*-*-*-*-*-*-*-*-*-*-*-*----*--**---*-**-*-*---*-*-*-*-*-*-*-*-*-* Ahora el Cliente: (Form2) Hay que hacer unas pocas modificaciones en el diseño: Luego no se olviden de las propiedades del TextBox1........ *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*- Codigo Cliente: Private Sub Command1_Click() Winsock1.SendData Text2.Text & vbCrLf Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "Cliente >" & Text2.Text & vbCrLf Text1.SelStart = Len(Text1.Text) Text2.Text = "" End Sub Private Sub Command2_Click() Winsock1.RemoteHost = Text3.Text Winsock1.RemotePort = Text4.Text Winsock1.Close Winsock1.Connect End Sub Private Sub Command3_Click() Winsock1.Close Text1.Text = Text1.Text & _ "*** Conexion cerrada por el usuario." & vbCrLf Text1.SelStart = Len(Text1.Text) End Sub Public Sub SendData(Paquete As String) If UCase(Paquete) = "/PING" Then Call AveriguarTiempoLlegada Exit Sub End If FrmMain.Winsock1.SendData Paquete End Sub Sub AveriguarTiempoLlegada() Dim Reply As ICMP_ECHO_REPLY Dim lngSuccess As Long Dim strIPAddress As String If SocketsInitialize() Then strIPAddress = Servidor.Ip lngSuccess = ping(strIPAddress, Reply) AddtoRichTextBox FrmMain.Text1, "Retardo: " & Reply.RoundTripTime & " Ms", 2, 51, 223, 1, 0 SocketsCleanup End If End Sub Private Sub winsock1_connect() Text1.Text = Text1.Text & _ "*** Conexion establecida." & vbCrLf Text1.SelStart = Len(Text1.Text) End Sub Private Sub winsock1_close() Winsock1.Close Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "*** Conexion cerrada por el servidor." & vbCrLf Text1.SelStart = Len(Text1.Text) 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) Winsock1.Close MsgBox "Error numero " & Number & ": " & Description, vbCritical End Sub Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim Buffer As String Winsock1.GetData Buffer Text1.SelStart = Len(Text1.Text) Text1.Text = Text1.Text & "Servidor >" & Buffer Text1.SelStart = Len(Text1.Text) End Sub -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Fuente: http://www.monografias.com/trabajos30/tutorial-visual-basic/tutorial-visual-basic.shtml (MODIFICADO) Imagenes alojadas en: http://www.elite-images.com.ar/ ------------------------------------------------------------*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Muchas gracias por participàr del Tutorial, cualquier Duda y/o error comentar, en lo posible no enviar MP.

[img] les voy a enseñar a cambiar la IP SIN PROGRAMAS!!! Miren: Yo lo hago con un Modem XyXEL de Telefonica [img] Lo voy a explicar con FOTOS hací no tienen problema. RECUERDEN: SPEEDY 3 Megas // ZyZEL // [img] el navegador Ej: [img] O [img] Explorer es muy lento. Si lo prefieren no cambia en nada. [img] en el navegador escriban esto: 192.168.1.1 FOTO: [img] aprieten en configuración avanzada y les saldrá un campo de usuario y contraseña. Ahí deben poner: Usuario: admin Password: admin Si no les funciona prueben con: admin / 1234 Y si no funciona empiecen a buscar la Password (Llamen a speedy) [img] que están adentro. FOTO: [img] en : Maintenance Y Luego Apreten en: SysRestart [img] revisen que en : System Restart with esté puesto : Current Settings FOTO: [img] aprieten en RESTART y les saltará un cartel que dice: ----- Luego de 15 segundos les saltará otro cartel que les dirá: ---- Justificación de "----" : Mi vieja está usando la notebook abajo y se cambio la IP se corta Internet por 15 SEGUNDOS. [img] esperan 10 segundos y ya pueden usar Internet con otra IP !! [img] UTILIZABLE PARA RAPIDSHARE HACÍ NO ESPERAN 20 MINUTOS PARA HACER OTRA DESCARGA[/color] Pueden revisar la IP en : MÍA [img] Y SORY POR LA CANTIDAD DE BARRAS SEPARADORAS!!!!!!! Si dejas un comentario te aparece ella en casa [img]