elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
29 Mayo 2012, 08:59  


Tema destacado: Sigue las noticias más importantes de elhacker.net en ttwitter!

+  Foro de elhacker.net
|-+  Programación
| |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo, raul338)
| | |-+  Recv Function Crash ( Noblocking Mode)
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Recv Function Crash ( Noblocking Mode)  (Leído 338 veces)
ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Recv Function Crash ( Noblocking Mode)
« en: 19 Julio 2011, 23:40 »

Good morning
 I try to make a Multithread socket .I pass the AcceptHandler in a new thread and Succesfully Workthread Start .
 The socket By Default is Blocking mode
 In blocking Mode Create Threads and can Send data to the Last Socket  Successfully
 If go to Set The Socket in NoBlocking Mode
Código:
Dim NonBlock As Long
 NonBlock = 1
 If ioctlsocket (nRet, FIONBIO, NonBlock) = SOCKET_ERROR Then
 WriteLog "Socket Cannot Set NoBlocking"
 End If
My project Run Succesfully Create the First thread and The Second(ListenThread).When Client Connect start the ClientThread(WorkThread)and Crash .
 My Workthread

Código:
Public Function Workthread (ByVal Param As Long) As Long
 Const MAX_BUFFER_LENGTH As Long = 8192 'Normal = 8192' MAX = 65536
 Dim Buffa (1 To MAX_BUFFER_LENGTH) As Byte
 Dim dBuff As String
 Dim ReadBuff As String
 Dim sRec As Long
 tID = GetCurrentThreadId
 Add_DataClientStore ClientCount, nRet, tID''/ / Store Data in a public type (sockid, threadid)
 WriteLog "New Client Arrive with Socket ID" & nRet & "On Thread ID:" & tID''/ / write data to listbox
 Do''While True

 ClientStore (ClientCount). Sock_ID = nRet
 sRec = recv (ClientStore (ClientCount). Sock_ID, Buffa (1), MAX_BUFFER_LENGTH, 0 &)
 ReadBuff = StrConv (Buffa, vbUnicode)
 [b]dBuff = Left $ (ReadBuff, sRec) [/b]
 WriteLog "Data Received.:" & DBuff & "Socket ID ..." & ClientStore (ClientCount). Sock_ID
 End If
 Loop
 End Function

The line to Crash is
dBuff = Left$(ReadBuff, sRec)
If Someone know anything
 Thanks for the time

 p.s Attach a ScreenShot with 505 Threads
 2:The Main thread and the Listenthread
 503 :Clients
 cpu usage =100%

This is the Error 
http://i54.tinypic.com/11qh94w.jpg
thanks for the time 
Good  night 


En línea
ntaryl

Desconectado Desconectado

Mensajes: 95



Ver Perfil
Re: Recv Function Crash ( Noblocking Mode)
« Respuesta #1 en: 20 Julio 2011, 21:21 »

Good evening

 Definetely my friends change a bit the Workthread and solve the Error
Código:
Public Function Workthread (ByVal Param As Long) As Long
 ThreadInit.InitThread
 Dim DBuff As String
 Dim ReadBuff As String
 Dim sRec As Long
 tID = GetCurrentThreadId
 Add_DataClientStore ClientCount, nRet, tID
 WriteLog "New Client Arrive with Socket ID" & nRet & "On Thread ID:" & tID
 Do''While True
 DBuff = Space (4096)
 ClientStore (ClientCount). Sock_ID = nRet
 sRec = recv (ClientStore (ClientCount). Sock_ID, ByVal DBuff, Len (DBuff), 0)
 If sRec <> 0 And sRec <> SOCKET_ERROR Then
 ReadBuff = ReadBuff & Left (DBuff, sRec)
 WriteLog "Data Received.:" & ReadBuff & "Socket ID ..." & ClientStore (ClientCount). Sock_ID
 End If
 DoEvents
 Loop
 End Function

My server running and create for every Client a Workthread
 When i have 5 clients for example connected and try to send data I can send only in the last connected in the list(5)
 I suspect the problem come from me
 Is someone know something ?
Thanks for the time


En línea
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Se me cambia de mode monitor a mode managed solo
Hacking Wireless
mEeLES 6 917 Último mensaje 21 Septiembre 2007, 06:07
por LaStDot
Plane crash versus car crash
Foro Libre
Randomize 6 908 Último mensaje 23 Agosto 2008, 01:41
por Carloswaldo
Ayuda con error de flujo de datos ->"is neither function nor member function; "
Programación C/C++
pasteles 1 904 Último mensaje 9 Septiembre 2008, 00:53
por Kasswed
Duda con recv
Programación C/C++
Flakito81 5 1,021 Último mensaje 2 Abril 2009, 14:01
por Eternal Idol
hook a recv sin ms detours?
Programación C/C++
while 2 1,459 Último mensaje 6 Octubre 2010, 23:25
por while
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines