Hey, I'm working on program that connects to a server and I need to get the user ID and display it in a textbox but I'm having trouble getting it from the packet recived.
Here is part of the packet - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
Where the xx xx xx xx is the server generates a user ID.
Does any 1 know how I could get this ID in a textbox using - Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Thanks.
13 2161
Does your code need to find the ID first, or is it at a known position?
This ID is in a known position - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
is the beginning of the packet. I thought I might have to do something like: - If InStr(buffer, Chr(0) & Chr(1) & Chr(8) & Chr(0))
To find the packet with the ID, and then something else to get the user ID from it's position, but I'm not sure.
This ID is in a known position - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
is the beginning of the packet. I thought I might have to do something like: - If InStr(buffer, Chr(0) & Chr(1) & Chr(8) & Chr(0))
To find the packet with the ID, and then something else to get the user ID from it's position, but I'm not sure.
Sorry, I also meant to ask, is the ID a known length, or do you have to determine where it finishes?
And is the packet received as pairs of hex digits separated by spaces as shown here? Or is it a simple string of byte values, which you have represented as hex pairs here for readability? In other words, would the above sample be received as 16 bytes, or 47?
Hm... actually, the bit about the Instr() probably answers that. I'm busy at work now, but should be able to help with this at lunch time (in a couple of hours), if someone doesn't beat me to it (my bet would be on willakawill).
The ID length is four pairs of hex digits represented by the x's. - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
The ID remains in the same place each time you connect.
The ID length is four pairs of hex digits represented by the x's. - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
The ID remains in the same place each time you connect.
Ah. So it's actually received in the same format you showed it here?
What I'm getting at is whether we need to do a conversion from a string of spaces and two-digit hex values to simple byte values, or whether it's just been rendered this way for display purposes, by a hex editor or something.
Or, to put it another way, does this sample data actually start with the ASCII string "00" (character 48, or &h30, repeated twice) or with a null byte? Sorry to harp on this, but I feel it's very important to ensure we're talking about the same thing.
It starts with 00 and there is a space between each pair of hex digits.
It starts with 00 and there is a space between each pair of hex digits.
Ok, now we're cooking with gas.
That means your suggestion of - If InStr(buffer, Chr(0) & Chr(1) & Chr(8) & Chr(0))
would have to be modified, something like - If InStr(buffer, "00 01 08 00")
-
or possibly
-
If Left(buffer, 11) = "00 01 08 00"
Note also, if you need to know the location within the packet, the Instr( ) function above will tell you where it is - just add 12 to what it returns.
I'm sure we can come up with a pretty simple routine to pull out the ID. I've just started work, again, so if someone doesn't beat me to it, I should be able to get back to it in a few hours, at lunch time.
Feel free to have a go at it yourself. It shouldn't be particularly difficult. Off the top of my head, I'd suggest you just isloate the pairs of characters with something like Mid( ), concatenate it with the string " &H" to make a recognisable hex value, use Val( ) to convert to a number, then use Chr( ) function to convert the number to an ASCII character. Then concatenate these characters them into a string.
Have fun... :)
I'm really busy, so I might leave you to play with this for a day or two. It'll be good practice, anyway.
Hey, I'm working on program that connects to a server and I need to get the user ID and display it in a textbox but I'm having trouble getting it from the packet recived.
Here is part of the packet - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
Where the xx xx xx xx is the server generates a user ID.
Does any 1 know how I could get this ID in a textbox using - Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Thanks.
u said that the packet is for example - 00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19
if u sure that "00 01 08 00 FF FF FC 19" and "FF FF FC 19" always the same and never change so its so easy u can use this small code to get the "xx xx xx xx" - dim x as string ' x = the recieved packet
-
x = replace("00 01 08 00 FF FF FC 19 xx xx xx xx FF FF FC 19","00 01 08 00 FF FF FC 19","")
-
x = replace ( x , "FF FF FC 19","")
-
msgbox "Username : " & x
-
i hope it help u
... - dim x as string ' x = the recieved packet (really?)
-
x = replace(<packet>,"00 01 08 00 FF FF FC 19","")
-
x = replace ( x , "FF FF FC 19","")
-
msgbox "Username : " & x
This seems like a nice, compact way to extract the user ID from the string (making certain assumptions about the initial string, of course). But you still need to convert the hex pairs to bytes, and put them together into either a byte array or a string.
I managed to do it like this: -
If InStr(buffer, Chr(0) & Chr(1) & Chr(8) & Chr(0) & "ÿÿü") Then
-
-
aaa = Split(buffer, "ÿÿü")
-
-
For c = 1 To Len(aaa(1))
-
bbb = Mid(aaa(1), c, 1)
-
-
bbb = Hex(Asc(bbb))
-
-
If Len(bbb) = "1" Then
-
bbb = "0" & bbb
-
End If
-
-
rdata = rdata & bbb & " "
-
Next
-
-
ccc = Left(rdata, Len(rdata) - 1)
-
-
-
Text3 = ccc
I managed to do it like this:...
Given the extracted ID from kZero's post, I'd probably do it something like this... - Dim strHex As String, strID As String, I As Long
-
' Set up some hex values to represent the input...
-
strHex = "41 42 43 44"
-
-
' Convert to a simple string...
-
For I = 1 To 10 step 3
-
strID = strID & Chr(Val("&H" & Mid(strHex, I, 2)))
-
Next
I haven't tested this (just typed it here), but I think it should work, leaving the user ID in strID.
Nobody help this loser newbie.
He needs help to create a program to hack digichat (www.digichat.com) chat rooms across the internet.
What a loser.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ophir |
last post by:
Hello all !
I wrote a simple ActiveX DLL to wrap winsock functionality so I can
use it in an ASP page.
I call it MyWinSock
In the Class module I use this declaration:
Dim ctlSocket as...
|
by: Yu Chai |
last post by:
Hi guys,
I created a ASP page that
1. users can run when WinSock proxy are using (ie's one is unchecked)
2. users can't run when WinSock proxy are using (ie's one is checked)
3. users can't run...
|
by: Glen Conway |
last post by:
Hi,
I'm trying to use the gethostbyname function from wsock32.dll and failing dismally Has anyone got a successful implementation of this in VB.NET? My ulitimate goal is to resolve NetBIOS names...
|
by: kc |
last post by:
Hi
Just upgrading a app from VB6 to VB.Net. All is going well apart from the
Winsock control.
The first thing we notice is that there does not appear to be a .Net version
(please correct me if...
|
by: kpaxoid |
last post by:
An odd problem. Application runs fine in the VB6 IDE, but when compiled, as soon as the application attempts to execute
Winsock.Listen 'Winsock is created by Winsock = New Winsock
the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |