|
-
Sep 2nd, 2005, 06:00 AM
#1
Thread Starter
New Member
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
-
Sep 2nd, 2005, 10:29 AM
#2
Frenzied Member
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?
-
Sep 2nd, 2005, 01:34 PM
#3
Lively Member
Re: How too send Packet in Hex in winsock
-
Sep 2nd, 2005, 04:34 PM
#4
Thread Starter
New Member
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.
-
Sep 2nd, 2005, 07:50 PM
#5
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:
Option Explicit
Private Sub Form_Load()
Dim msg$
msg = StringToHex("David")
MsgBox msg
MsgBox HexToString(msg)
End Sub
Function HexToString(ByVal sText As String) As String
Dim saHex() As String, i As Long
saHex = Split(sText)
For i = 0 To UBound(saHex)
HexToString = HexToString & ChrW("&H" & saHex(i))
Next
End Function
Function StringToHex(ByVal tIn As String) As String
Dim tout$
Dim x As Integer
tIn = "David"
For x = 1 To Len(tIn)
tout = tout & CStr(Hex(Asc(Mid(tIn, x, 1)))) & " "
Next x
tout = Left$(tout, Len(tout) - 1)
StringToHex = tout ' 44 61 76 69 64
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.
-
Sep 2nd, 2005, 08:44 PM
#6
Thread Starter
New Member
Re: How too send Packet in Hex in winsock
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|