Code Cliente:
Código:
Private Sub Command1_Click()
Estado.Caption = "Enviando petición de imagen.."
TCP.SendData "imagen"
End Sub
Private Sub Command2_Click()
TCP.RemoteHost = IP.Text
TCP.RemotePort = 1359
TCP.Connect
End Sub
Private Sub Form_Load()
Dim existelafoto As Boolean
If Existe(App.Path & "\tmp.png") Then
existelafoto = True
Else
existelafoto = False
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
TCP.Close
End Sub
Private Sub TCP_Close()
Estado.Caption = "Conexión cerrada"
End Sub
Private Sub TCP_Connect()
Estado.Caption = "Conectado"
End Sub
Private Sub TCP_DataArrival(ByVal bytesTotal As Long)
Estado.Caption = "Recibiendo imagen.."
Dim arxivo As String
Dim numero As Integer
numero = 1
While existelafoto = True
If Existe(App.Path & "\imagen" & numero & ".jpg") <> 0 Then
numero = numero + 1
Else
existelafoto = False
End If
Wend
Dim datos As String
TCP.GetData datos
arxivo = arxivo & datos
Open App.Path & "\imagen" & numero & ".jpg" For Binary As #1
Put #1, , arxivo
Close #1
If Existe(App.Path & "\imagen1.jpg") <> 0 Then
existelafoto = True
Else
existelafoto = False
End If
Estado.Caption = "Imagen recibida"
End Sub
Private Sub TCP_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)
Estado.Caption = "Error " & Number
End Sub
Public Function Existe(sArchivo As String) As Integer
Existe = Len(Dir$(sArchivo))
End Function
Y el Server:
Código:
Private Sub Command1_Click()
Form1.Visible = False
End Sub
Private Sub Form_Load()
TCP.Close
TCP.LocalPort = 1359
TCP.Listen
End Sub
Private Sub TCP_ConnectionRequest(ByVal requestID As Long)
TCP.Close
TCP.Accept requestID
End Sub
Private Sub TCP_DataArrival(ByVal bytesTotal As Long)
Dim datos As String
TCP.GetData datos
If datos = "imagen" Then
captura.Area = Pantalla
captura.captura
imagenTemporal.Picture = captura.Imagen
SavePicture imagenTemporal.Picture, App.Path & "\imagentemporal.jpg"
Dim Buf As String * 1024
Dim Todo As String
Open App.Path & "\imagentemporal.jpg" For Binary As #1
Do While Not EOF(1)
DoEvents
Get #1, , Buf
Todo = Todo & Buf
Loop
Close #1
TCP.SendData Todo
End If
End Sub
/code]
me sale error 10061