Results 1 to 6 of 6

Thread: How too send Packet in Hex in winsock

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    How too send Packet in Hex in winsock

    I need to know how too send a packet to the server in hex any ideas thank you

  2. #2
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: How too send Packet in Hex in winsock

    Please elaborate!

    1) What do you mean by hex? "send a packet to the server in hex" is too ambiguous.
    2) What are you trying to do?

  3. #3
    Lively Member
    Join Date
    May 2005
    Posts
    90

    Re: How too send Packet in Hex in winsock

    Language?
    ^_^

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    Re: How too send Packet in Hex in winsock

    I would like to connect to a remote host send a line of data in hex not text.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How too send Packet in Hex in winsock

    Why? The only way to do that would be to loop thru the line of text, and use the HEX() function to convert each letter's ASC() value into a hex character.
    I added a space between each character in this example
    VB Code:
    1. Option Explicit
    2.  
    3. Private Sub Form_Load()
    4.   Dim msg$
    5.   msg = StringToHex("David")
    6.   MsgBox msg
    7.   MsgBox HexToString(msg)
    8. End Sub
    9.  
    10. Function HexToString(ByVal sText As String) As String
    11.     Dim saHex() As String, i As Long
    12.     saHex = Split(sText)
    13.     For i = 0 To UBound(saHex)
    14.         HexToString = HexToString & ChrW("&H" & saHex(i))
    15.     Next
    16. End Function
    17.  
    18. Function StringToHex(ByVal tIn As String) As String
    19.   Dim tout$
    20.   Dim x As Integer
    21.   tIn = "David"
    22.   For x = 1 To Len(tIn)
    23.     tout = tout & CStr(Hex(Asc(Mid(tIn, x, 1)))) & " "
    24.   Next x
    25.   tout = Left$(tout, Len(tout) - 1)
    26.   StringToHex = tout ' 44 61 76 69 64
    27. End Function

    I also added a conversion back. As you see, the strings are a lot bigger if they are in hex separated by spaces (so that they can be split.

  6. #6

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    3

    Re: How too send Packet in Hex in winsock

    thanks man

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