Free ebook 
Free Visual Basic and Winsock ebook. Free ebook - TCP client - server. Winsock State sckConnected
  [ Winsock ]    [ Main page ]

    Visual Basic Winsock sckConnected
    Ebook. Returns the state of the socket connection.
    

Visual Basic TCP Client-Server


    
    TCP Client-Server >>

    Visual Basic
    
    Once you have established a connection with another computer, you want to be able to send data through this connection. The SendData () method gets the string that should be sent to the remote node. It returns true if the operation was successful. If any errors occur, you can get additional information using the errorcode and the error description property. Sending data through a socket is a simple matter of using the send () function.
    
     Public Function SendData(ByVal strData As String) As Boolean
    Dim WSAResult As Long, i As Long, l As Long
    
      l = Len(strData)
      ReDim Buff(l + 1) As Byte
    
      For i = 1 To l
        Buff(i - 1) = Asc(Mid(strData, i, 1))
      Next
      Buff(l) = 0
    
      WSAResult = send(mlngSocket, Buff(0), l, 0)
      If WSAResult = SOCKET_ERROR Then
        SetLastErrorCode "Error en SendData::send"
        SendData = False
      Else
        SendData = True
      End If
    End Sub
    
    The first parameter passed to this function is the socket connection through which data is transferred. The second parameter is a pointer to a buffer containing the data to send. This buffer is an array of bytes passed directly to the function. To pass an entire numeric array, you pass the first element of the array by reference. This works because the data of a numeric array is always laid out sequentially in memory. The third parameter is the number of bytes to send. The last parameter passed to the send () function is a flag that tells the socket how to send data. We do not need special shipping instructions, so this flag is zero. The send () function returns the number of bytes sent if no error occurred, and in this case returns the result code SOCKET_ERROR. Since we use blocking functions, the send () function will not return until the data has been completely sent or an error has occurred.
    
    
DOWNLOAD List >>
    
    Visual Basic Source Code. TCP Client-Server

    

Visual Basic TCP Client-Server


    Free ebook Free Visual Basic and Winsock ebook. Free ebook - TCP client - server. Winsock State sckConnected

Visual Basic. Free Visual Basic and Winsock ebook. Free ebook - TCP client - server. Winsock State sckConnected TCP Winsock
Winsock sckConnected