Results 1 to 11 of 11

Thread: MSWinsock attacks!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    MSWinsock attacks!

    Index 0 is just the listening port, for accepting, >0 are the slots for sessions.

    ¿How comes that this little piesce of code is called with INDEX = 0 dozens of times, within the same second. When the code requires like 4 or 5 seconds of reaction time to setup the listening port again once it is closed or errored.?


    Code:
    Public Sub SocketCyberControl_Error(Index As Integer, 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)
    Dim Session As Integer
    
    On Error Resume Next
    
    If Index > 0 Then
        ' Cierra el slot.
        CyberControlSlotInUse(Index - 1) = False
        
        ' Avisa al servidor central si es necesario.
        If LenB(CyberControlUserNameLogued(Index - 1)) Then
            Call ClanUnlockIfUnused(CyberControlUserNameLogued(Index - 1))
        End If
        
        ' Actualiza LastCyberControlSlotInUse.
        Call Update_LastCyberControlSlotInUse
        
        If LenB(CyberControlUserNameLogued(Index - 1)) Then
            ' Tenía un usuario logueado.
            Call IfNowhereRemoveNick(CyberControlUserNameLogued(Index - 1))
        End If
        
        If LenB(CyberControlNameID(Index - 1)) Then
            ' El socket tenía una identificación.
            Call RemNickPCNameIF(CyberControlNameID(Index - 1))
            ' Avisa del cierre del cliente de cybercontrol a los operadores o gerentes.
            Call CyberControl_EventCloseError(CyberControlNameID(Index - 1))
        End If
    Else
        ' Se cerró el socket escucha.
        Call AdmLoging("Server", 3, "Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: " + Description)
        ' // No se puede descargar el socket acá, lo hará luego. //
        CyberControlListeningPort = False
        CyberControlListeningPortStage = 0
    End If
    
    End Sub
    when these variable are set this way
    CyberControlListeningPort = False
    CyberControlListeningPortStage = 0

    that mean a timer will wait some seconds, close / unload the socket, create / bind / listen the socket again, it is a cycle like 5 seconds in total done in part, for just wait for akn or whatever from the socket side.

    so, is virtually impossible, that _ERROR event is called with INDEX = 0 unless really the index variable is not filled correctly for the event call.


    LOG:

    Code:
    // 06-21-2018 08:27:59 //[Server]: Advertencia, los servicios para Master Control Client se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    // 06-21-2018 08:28:00 //[Server]: Advertencia, los servicios para CyberControlClient se cayeron ante un error del sistema operativo / firewall / hardware / red. Error: Socket is non-blocking and the specified operation will block
    HOST is win 2012 R2 server, full updated, I see this kind of logs in several customers, win 2008 server, 2012, 2016, win 10, win 7 whatever.

    Sockes sessuibs are fully awate of SendComplete, and that they can't transmitt if there is something waiting for the SendComplete event, so outputs are all buffered, these are LAN speeds, etc etc.




    this is the code which re-do the index 0 inside a timer of 5 seconds time lapse.

    Code:
    Select Case CyberControlListeningPortStage
        Case Is = 0
            ' Descarga el socket y espera 5 segundos.
            On Error Resume Next
            FormID.SocketCyberControl(0).Close
            Unload FormID.SocketCyberControl(0)
            CyberControlListeningPortStage = CyberControlListeningPortStage + 1
        Case Is = 1
            ' Inicializa puerto escucha.
            On Error GoTo ErrToListenSocketCyberControl
            If CyberControlListeningPort = False Then
                ' Preparación del socket para el servicio de CyberControl.
                If LenB(ForcedLocalIP) = 0 Then
                    FormID.SocketCyberControl(0).Protocol = sckTCPProtocol
                    FormID.SocketCyberControl(0).LocalPort = CONFIG_CyberControl_LocalPort
                    FormID.SocketCyberControl(0).Listen
                Else
                    FormID.SocketCyberControl(0).Protocol = sckTCPProtocol
                    FormID.SocketCyberControl(0).Bind CONFIG_CyberControl_LocalPort, ForcedLocalIP
                    FormID.SocketCyberControl(0).Listen
                End If
                ' Indica que lo ha inicializado.
                CyberControlListeningPort = True
            End If
            CyberControlListeningPortStage = CyberControlListeningPortStage + 1
        Case Is = 2
            ' Ok, done.
    End Select
        
    Exit Sub

    _Error events is not called manually anywhere, only when calle by the mswinsck.

    so, tired of this kind of behaviour about mswinsck.
    Last edited by flyguille; Jun 21st, 2018 at 11:49 AM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    Connection request same socket pool

    Code:
    Private Sub SocketCyberControl_ConnectionRequest(Index As Integer, ByVal requestID As Long)
    Dim NewSlot As Integer, Error As Byte
    
    Call GetNewCyberControlSocket(NewSlot, Error)
    If Error = 0 Then
        ' Hay espacio para atender al cliente de CyberControl.
        ' Descarga el socket por si estaba cargado.
        ' // A tener en cuenta que la correspondencia es "NUMERO DE SOCKET = NUMERO DE SLOT + 1". //
        On Error GoTo ErrNoLoad
        If CyberControlSocketIsLoaded(NewSlot) = False Then
            ' Si el socket no estaba cargado, lo crea.
            Load SocketCyberControl(NewSlot + 1)
            ' indica que ya creó el socket.
            CyberControlSocketIsLoaded(NewSlot) = True
        End If
        On Error GoTo ErrNoAccept
        SocketCyberControl(NewSlot + 1).LocalPort = 0
        SocketCyberControl(NewSlot + 1).Accept requestID
        
        ' // No se informa el evento aún porque en esta etapa el cliente aún no se identificó. //
    End If
    
    Exit Sub
    
    
    
    ErrNoLoad:
    Resume ErrNoLoad2
    ErrNoLoad2:
    
    CyberControlSlotInUse(NewSlot) = False
    
    Exit Sub
    
    
    
    ErrNoAccept:
    Resume ErrNoAccept2
    ErrNoAccept2:
    
    ' No pudo conectar, devuelve el slot.
    CyberControlSlotInUse(NewSlot) = False
    
    End Sub

    _SEND COMPLETE event

    Code:
    Private Sub SocketCyberControl_SendComplete(Index As Integer)
    
    On Error GoTo Err
    
    If Index > 0 Then
        ' Verifica la versión de transmisión.
        Select Case CyberControlConVersion(Index - 1)
            Case Is = 1
                ' VT1.
                
                ' Verifica si hay algo más para transmitir.
                If CyberControlOutputBuffer(Index - 1).BufLen Then
                    ' Hay algo más para transmitir.
                    FormID.SocketCyberControl(Index).SendData CyberControlOutputBuffer(Index - 1).BufMid(1, 2048)
                    ' If SendData error, don't executes the deletion from the buffer is not done.
                    CyberControlOutputBuffer(Index - 1).Delete 2048
                    ' Verifica si hay algo más para transmitir.
                    If CyberControlOutputBuffer(Index - 1).BufLen Then
                        ' Hay algo más.
                        CyberControlSendIsCompleted(Index - 1) = False
                    Else
                        ' Ya se transmitió todo.
                        CyberControlSendIsCompleted(Index - 1) = True
                    End If
                Else
                    ' No había nada más para transmitir.
                    CyberControlSendIsCompleted(Index - 1) = True
                End If
            Case Is = 2
                ' VT2.
        
                ' Verifica si hay algo más para transmitir.
                If CyberControlByteOutputBuffer(Index - 1).BufLen Then
                    ' Hay algo más para transmitir.
                    FormID.SocketCyberControl(Index).SendData CyberControlByteOutputBuffer(Index - 1).BufMid(0, 2048)
                    ' If SendData error, don't executes the deletion from the buffer is not done.
                    CyberControlByteOutputBuffer(Index - 1).BufDelete 2048
                    ' Verifica si hay algo más para transmitir.
                    If CyberControlByteOutputBuffer(Index - 1).BufLen Then
                        ' Hay algo más.
                        CyberControlSendIsCompleted(Index - 1) = False
                    Else
                        ' Ya se transmitió todo.
                        CyberControlSendIsCompleted(Index - 1) = True
                    End If
                Else
                    ' No había nada más para transmitir.
                    CyberControlSendIsCompleted(Index - 1) = True
                End If
        End Select
    End If
    
    Exit Sub
    
    
    
    Err:
    Resume Err2
    Err2:
    
    ' Indica que falló al transmitir.
    CyberControlSendIsCompleted(Index - 1) = False
    
    End Sub

    And the TRANSMISSION how it handles the .SEND in chunks of 2KB.

    Code:
    Public Sub CyberControlSendDataToSlot(ByVal SlotIndex As Integer, Error As Byte, ByVal Comando As Integer, Optional ByVal Param1 As String, Optional ByVal Param2 As String, Optional ByVal Param3 As String, Optional ByVal Param4 As String)
    Dim Length As Long, DataToSend As String
    Dim b() As Byte, L(0 To 2) As Byte
    
    ' ******************************
    ' * Error:                     *
    ' * 0 = Ok.                    *
    ' * 1 = Error de transmisión.  *
    ' * 2 = Error, slot cerrado.   *
    ' * 3 = Data muy grande.       *
    ' ******************************
    
    If CyberControlSlotInUse(SlotIndex) Then
        ' Si ocurre un error al enviar los datos se debe cerrar el socket.
        On Error GoTo Err
        ' Ensambla el mensaje y lo encripta.
        Select Case CyberControlConVersion(SlotIndex)
            Case Is = 1
                ' VT1.
                
                DataToSend = Encript(Comando, Param1, Param2, Param3, Param4, .....)
                ' Verifica que la data sea transmitible.
                Length = Len(DataToSend)
                If Length < 65536 Then
                    ' Agrega el header del encapsulado.
                    DataToSend = Chr$(Length Mod 256) + Chr$(Length \ 256) + DataToSend
                    ' Envía los datos.
                    CyberControlOutputBuffer(SlotIndex).BufAdd DataToSend
                    ' Verifica si puede transmitir ahora.
                    If CyberControlSendIsCompleted(SlotIndex) Then
                        ' Extrae, transmite y elimina chunk.
                        FormID.SocketCyberControl(SlotIndex + 1).SendData CyberControlOutputBuffer(SlotIndex).BufMid(1, 2048)
                        ' If SendData error, don't executes the deletion from the buffer is not done.
                        CyberControlOutputBuffer(SlotIndex).Delete 2048
                        ' Verifica si hay algo más para transmitir.
                        If CyberControlOutputBuffer(SlotIndex).BufLen Then
                            ' Hay algo más.
                            CyberControlSendIsCompleted(SlotIndex) = False
                        Else
                            ' Ya transmitió todo.
                            CyberControlSendIsCompleted(SlotIndex) = True
                        End If
                    End If
                    Error = 0
                Else
                    Error = 3
                End If
            Case Is = 2
                ' VT2.
                
                b() = ByteEncript(Comando, Param1, Param2, Param3, Param4, ....)
                ' Verifica que la data sea transmitible.
                Length = UBound(b()) + 1
                If Length < 16777216 Then
                    ' Agrega el header del encapsulado.
                    L(0) = (Length Mod 256&) Xor &HBF
                    L(1) = (Int(Length / 256&) Mod 256&) Xor &HA5
                    L(2) = Int(Length / 65536) Xor &H62
                    ' Envía los datos.
                    CyberControlByteOutputBuffer(SlotIndex).BufAdd L()
                    CyberControlByteOutputBuffer(SlotIndex).BufAdd b()
                    ' Verifica si puede transmitir ahora.
                    If CyberControlSendIsCompleted(SlotIndex) Then
                        ' Extrae, transmite y elimina chunk.
                        FormID.SocketCyberControl(SlotIndex + 1).SendData CyberControlByteOutputBuffer(SlotIndex).BufMid(0, 2048)
                        ' If SendData error, don't executes the deletion from the buffer is not done.
                        CyberControlByteOutputBuffer(SlotIndex).BufDelete 2048
                        ' Verifica si hay algo más para transmitir.
                        If CyberControlByteOutputBuffer(SlotIndex).BufLen Then
                            ' Hay algo más.
                            CyberControlSendIsCompleted(SlotIndex) = False
                        Else
                            ' Ya transmitió todo.
                            CyberControlSendIsCompleted(SlotIndex) = True
                        End If
                    End If
                    Error = 0
                Else
                    Error = 3
                End If
        End Select
    Else
        Error = 2
    End If
    
    Exit Sub
    
    
    
    Err:
    Resume Err2
    Err2:
    
    ' Indica que no pudo transmitir.
    CyberControlSendIsCompleted(SlotIndex) = False
    
    End Sub

    by the way, VT1 is old ANSI protocol, not actually in use anymore, what is running is VT2 byte array transmission.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    Seriusly, what is the limit of the mswinsck.... I am making sure there is 2KB transmission as maximun per socket, when "// 06-21-2018 08:28:00 //[Server]:....... Error: Socket is non-blocking and the specified operation will block" that errors comes, it is dropping everybody, but with INDEX 0!!!!!!!! in the event ERROR, so it forces my code to re-launch the listening port, because was designed that way.

    So, if there is a peak usage, by example, 20 PCs getting 2K data, are 40K each seconds, that makes the whole mswinsck to get out of internal memory? it is 64K? , so , then mswinsock is really unusable for server side!.

    and It triggers WRONGFULLY the _ERROR event... bada tussssssssssssssssssssssssssssssss.....

  4. #4
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: MSWinsock attacks!

    No, there is no 64KB limit and yes, winsock usercontrol in unusable for internet-scale servers as it's using hwnd messages to do async sockets (not IOCP as IIS and most internet servers impl on Windows).

    But then 20 simultaneous clients is ridiculously small -- so search for some kind of error in client (your) code first.

    cheers,
    </wqw>

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    I understand the message things, it is a problem.

    But coming to my code layer, the which can be programmed in VB6 as normal VB6, there is no any possibility, to trigger errors on INDEX = 0, there is no manual call to _ERROR , and it is normally on moderated traffic, working just fine.

    But, let say , if the admin resets the server, and on a sudden there is 20 PCs trying to connect to the server , all togheter, the "Socket is non-blocking and the specified operation will block" error is logged, and that error only can be as the text is logged from the _ERROR event, not the _CLOSE event.

    And as logged it is about index = 0, so, the index which is used only to listen for new incomming connections.

    NO, no the _SendMessage, or the DataArrival, or the .Send procedure, do anything with the INDEX = 0, because, there is a simple IF in those procedure, just in case on an higher layer is it called wrongfully.

    Include the Drop slot, procedure, can´t do anything with INDEX =0.

    And is not only that, there is other arrays, with similar structure, running parallelly services, for others modules at clients hosts.

    And not only that, there is single socket client side for uplink connection, and is two more single sockets for others modules, and when the server is loaded passing certain load, it starts giving that error on several different sockets type.

    Now, I expect the sessions, like index = 1 , 2 ,3 -.... go and drop.... but not index 0!!!! and not only that DOZENS of time in the same second RTC.


    So, if I understand you, the "Socket is non-blocking and the specified operation will block", is more related to the hwnd message queue is being full ?, because .SEND generate a message for outputing to that message queue?.
    Last edited by flyguille; Jun 21st, 2018 at 07:51 PM.

  6. #6
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: MSWinsock attacks!

    Not sure what you are trying to do, or whether you are using mswsock.dll/ws2_32.dll or MSWINSCK.OCX, but it sounds like you are receiving multiple Error 100035 (WSAEWOULDBLOCK).

    Sending of IP data is relatively slow compared to the speed of a modern computer, and until Winsock has finished sending what is currently in it's buffer, it would normally block further data from being sent to the buffer by suspending the thread. But since VB6 does not support thread blocking, error 100035 is triggered. The program should wait for Winsock to send notification that it is ready to accept more data. This process is demonstrated here:
    http://www.vbforums.com/showthread.p...B-SimpleServer

    J.A. Coutts

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    Quote Originally Posted by couttsj View Post
    Not sure what you are trying to do, or whether you are using mswsock.dll/ws2_32.dll or MSWINSCK.OCX, but it sounds like you are receiving multiple Error 100035 (WSAEWOULDBLOCK).

    Sending of IP data is relatively slow compared to the speed of a modern computer, and until Winsock has finished sending what is currently in it's buffer, it would normally block further data from being sent to the buffer by suspending the thread. But since VB6 does not support thread blocking, error 100035 is triggered. The program should wait for Winsock to send notification that it is ready to accept more data. This process is demonstrated here:
    http://www.vbforums.com/showthread.p...B-SimpleServer

    J.A. Coutts
    But I already do that, PER SOCKET, each socket is capable of sending chunks of 2KB each time, then they wait for the _SendComplete to send more if exists more.

    on the Main Send procedure it don't transmitt anything if the socket is waiting for a SendComplete.

    Code:
                    ' Envía los datos.
                    CyberControlOutputBuffer(SlotIndex).BufAdd DataToSend
                    ' Verifica si puede transmitir ahora.
                    If CyberControlSendIsCompleted(SlotIndex) Then
                        ' Extrae, transmite y elimina chunk.
                        FormID.SocketCyberControl(SlotIndex + 1).SendData CyberControlOutputBuffer(SlotIndex).BufMid(1, 2048)
                        ' If SendData error, don't executes the deletion from the buffer is not done.
                        CyberControlOutputBuffer(SlotIndex).Delete 2048
                        ' Verifica si hay algo más para transmitir.
                        If CyberControlOutputBuffer(SlotIndex).BufLen Then
                            ' Hay algo más.
                            CyberControlSendIsCompleted(SlotIndex) = False
                        Else
                            ' Ya transmitió todo.
                            CyberControlSendIsCompleted(SlotIndex) = True
                        End If
                    End If
                    Error = 0
    CyberControlSendIsCompleted(SlotIndex) flags if the SendComplete was triggered or not.

    -----------------

    I am assuming now, by this experience, is that mswinsck don't work on output buffer PER EACH SOCKET....

    -------------------

    And then is the problem, it calls _ERROR event on index=0 which is the listening port.

    This last problem was completely unexpected, I was prepared for some session to be dropped by the mentioned error, a single session recover fast, no problem with that, but I wasn't prepared to _error being called with index 0 without no reason.

    So, I can try to set the listening port on a completely different socket name single socket, and let the sessions to run run from index 0 up to maximun, instead of index 1 up to maximun. I can try that. If it is a mswinsck malfunction it will fix that.

    But now, I found the needs to do like a global semaphore for stop all socket from transmitt globaly, not per each socket.....


    IT IS quite weird, because I have made others modules like DCC file send protocol on mswinsck and it can do like 8MBps of file transmission, but they are an array of objects which works like single socket, just one per object (form). in an ActiveX.exe scenario, a completely different scenario.


    Hmmmmmmmmm, oh!, that means IF I set a socket per each form, dinamically creating forms for each socket in the array, maybe it will break that buffer limit or push it far away?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    I find that the flag for IsCompleted is not properly handled in my code. It is based on output buffer variable, asking there is more to transmitt?, and not for hold it until _SendCompleted.

    But triggering that error, let me know that I am in the shadows.

    1) don't know if the BLOCKING error is per socket, or is per the whole process. Handling it PER socket it is easy, handling it per whole process it is a nightmare.

    So the question, if in a given peak usage, one socket can't send data, that means all others socket also can't send data at that moment?.



    and then, why it is _ERROR event called with index=0 , there is not usage on that index. Include the socket.Accept is done in the opening session index which is +1 to maximun.

    Unless the .ConnectionRequest EVENT also can fail with BLOCKING error. That is the only one actually using Index=0.

    So, I don't exit from the shadows at all.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    more question is, what if the .Send a second chunk inside the _SendComplete event also fail with BLOCKING error...., there won't be another SendComplete event triggered for that socket, so, there will be things on the output buffer variable which will hold , and ruining the timming.

    So on a Timer must be done some re-try sending for all sockets which has something in the output buffer. And that will bring back the Blocking error.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2013
    Posts
    894

    Re: MSWinsock attacks!

    Well, now I do use properly the wait until SendComplete var flag.

    But, I am stil in the shadows.

    If the BLOCKING error is triggered when execute the Socket.Send method, and it can ON ERROR GOTO that, .... For what is the _ERROR event triggering the BLOCKING error?, I mean if it is just a .Sent related error, and is trap inmediately, what does call the Socket_Error event with that error code?.

    And then, why it is on Index 0, and not on sessions Indexes.

  11. #11
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,470

    Re: MSWinsock attacks!

    Quote Originally Posted by flyguille View Post
    Well, now I do use properly the wait until SendComplete var flag.

    But, I am stil in the shadows.

    If the BLOCKING error is triggered when execute the Socket.Send method, and it can ON ERROR GOTO that, .... For what is the _ERROR event triggering the BLOCKING error?, I mean if it is just a .Sent related error, and is trap inmediately, what does call the Socket_Error event with that error code?.

    And then, why it is on Index 0, and not on sessions Indexes.
    I don't know how MSWINSCK works internally, but at the socket level itself, each socket has it's own Send and Receive buffer. The maximum size of that buffer will vary with the operating system. 32 bit Windows Vista has a maximum buffer size of 8,192 bytes, and 64 bit Win 8.1 has a maximum buffer size of 65,536 bytes. The size can be determined by this API call:
    Code:
    Private Const SOL_SOCKET As Long = 65535
    Private Const SO_SNDBUF         As Long = &H1001&
    Private Const SO_RCVBUF         As Long = &H1002&
    
    Private Declare Function API_GetSockOpt Lib "ws2_32.dll" Alias "getsockopt" (ByVal s As Long, ByVal level As Long, ByVal optname As Long, optval As Any, optlen As Long) As Long
    
        If m_Protocol = SCK_TCP Then
            lRet = API_GetSockOpt(m_hSocket, SOL_SOCKET, SO_RCVBUF, lBuffer, LenB(lBuffer))
            If lRet = SOCKET_ERROR Then
                lErrorCode = Err.LastDllError
                Call m_Callback.Error(m_Index, lErrorCode, GetErrorDescription(lErrorCode), Routine)
            Else
                m_lRecvBufferLen = lBuffer
            End If
            lRet = API_GetSockOpt(m_hSocket, SOL_SOCKET, SO_SNDBUF, lBuffer, LenB(lBuffer))
            If lRet = SOCKET_ERROR Then
                lErrorCode = Err.LastDllError
                Call m_Callback.Error(m_Index, lErrorCode, GetErrorDescription(lErrorCode), Routine)
            Else
                m_lSendBufferLen = lBuffer
            End If
        End If
    J.A. Coutts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width