Hi guys, i am looking this sample code and try get some help.
http://www.vbdotnetforums.com/showthread.php?p=23514#post23514
I try extend code for upload file .jpg in server.
http://www.elguille.info/colabora/puntoNET/PabloTilli_SocketsVBNET.htm
Some can help me in extend code in SUB when string is recibed for recibe file too.
--------------------------------------------------------------------------------
Private Sub LeerSocket()
Dim IDReal As Net.IPEndPoint 'ID del cliente que se va a escuchar
Dim Recibir() As Byte 'Array utilizado para recibir los datos que llegan
Dim InfoClienteActual As InfoDeUnCliente 'Informacion del cliente que se va escuchar
Dim Ret As Integer = 0
IDReal = IDClienteActual
InfoClienteActual = Clientes(IDReal)
With InfoClienteActual
While True
If .Socket.Connected Then
Recibir = New Byte(100) {}
Try
'Me quedo esperando a que llegue un mensaje desde el cliente
Ret = .Socket.Receive(Recibir, Recibir.Length, SocketFlags.None)
If Ret > 0 Then
'Guardo el mensaje recibido
.UltimosDatosRecibidos = Encoding.ASCII.GetString(Recibir)
Clientes(IDReal) = InfoClienteActual
'Genero el evento de la recepcion del mensaje
RaiseEvent DatosRecibidos(IDReal)
Else
'Genero el evento de la finalizacion de la conexion
RaiseEvent ConexionTerminada(IDReal)
Exit While
End If
Catch e As Exception
If Not .Socket.Connected Then
'Genero el evento de la finalizacion de la conexion
RaiseEvent ConexionTerminada(IDReal)
Exit While
End If
End Try
End If
End While
Call CerrarThread(IDReal)
End With
End Sub
--------------------------------------------------------------------------------
Thank you.
http://www.vbdotnetforums.com/showthread.php?p=23514#post23514
I try extend code for upload file .jpg in server.
http://www.elguille.info/colabora/puntoNET/PabloTilli_SocketsVBNET.htm
Some can help me in extend code in SUB when string is recibed for recibe file too.
--------------------------------------------------------------------------------
Private Sub LeerSocket()
Dim IDReal As Net.IPEndPoint 'ID del cliente que se va a escuchar
Dim Recibir() As Byte 'Array utilizado para recibir los datos que llegan
Dim InfoClienteActual As InfoDeUnCliente 'Informacion del cliente que se va escuchar
Dim Ret As Integer = 0
IDReal = IDClienteActual
InfoClienteActual = Clientes(IDReal)
With InfoClienteActual
While True
If .Socket.Connected Then
Recibir = New Byte(100) {}
Try
'Me quedo esperando a que llegue un mensaje desde el cliente
Ret = .Socket.Receive(Recibir, Recibir.Length, SocketFlags.None)
If Ret > 0 Then
'Guardo el mensaje recibido
.UltimosDatosRecibidos = Encoding.ASCII.GetString(Recibir)
Clientes(IDReal) = InfoClienteActual
'Genero el evento de la recepcion del mensaje
RaiseEvent DatosRecibidos(IDReal)
Else
'Genero el evento de la finalizacion de la conexion
RaiseEvent ConexionTerminada(IDReal)
Exit While
End If
Catch e As Exception
If Not .Socket.Connected Then
'Genero el evento de la finalizacion de la conexion
RaiseEvent ConexionTerminada(IDReal)
Exit While
End If
End Try
End If
End While
Call CerrarThread(IDReal)
End With
End Sub
--------------------------------------------------------------------------------
Thank you.