Valhalla Legends Forums Archive | Visual Basic Programming | Sending/Recieving Packets

AuthorMessageTime
dodge
I was windering if anyone knew of a site that throughly explained how to send/recieve packets. Or maybe someone could give me an example? I searched google and I still am but I can't find anything besides forums you have to sign up tio see a responce. :-\
May 18, 2004, 1:16 PM
Grok
[quote author=dodge link=board=5;threadid=6862;start=0#msg60640 date=1084886208]
I was windering if anyone knew of a site that throughly explained how to send/recieve packets. Or maybe someone could give me an example? I searched google and I still am but I can't find anything besides forums you have to sign up tio see a responce. :-\
[/quote]

You did not specify a language or platform. We need to know whether you are using Windows, Linux, Solaris, and then the programming language.
May 18, 2004, 3:14 PM
iago
Since he didn't specify a platform, I'm going to have to assume he's using Java:

[code]void testfunc() throws Exception
{
Socket s = new Socket(INetAddress.getAddrFromName("http://www.google.ca"));
s.getOutputStream().write("GET / http/1.1\nHost:www.google.ca\n\n".getBytes());

while(true)
System.out.print((char) s.getInputStream().read();
}
[/code]
May 18, 2004, 3:19 PM
dodge
whoops sorry, I'm using VB. In the long run a bnet bot but im not there yet.
May 18, 2004, 5:02 PM
LoRd
Send:
[code]Winsock.SendData[/code]
Receive:
[code]Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Winsock.GetData
End Sub[/code]
May 18, 2004, 5:10 PM
Grok
[quote author=LoRd[nK] link=board=5;threadid=6862;start=0#msg60664 date=1084900257]
Send:
[code]Winsock.SendData[/code]
Receive:
[code]Private Sub Winsock_DataArrival(ByVal bytesTotal As Long)
Winsock.GetData
End Sub[/code]
[/quote]

Neither of those work.
May 18, 2004, 5:30 PM
iago
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately. I forget how to do it, but I suspect it's under the Project menu, under components maybe? Something like ctrl-t? My brain hurts :/

Also, giving those functions parameters would help too.

And I guess that means I typed that Java code for nothing. Oh well :)

[moves this topic to VB forum]
May 18, 2004, 5:40 PM
LoRd
[quote author=iago link=board=31;threadid=6862;start=0#msg60669 date=1084902029]
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately. I forget how to do it, but I suspect it's under the Project menu, under components maybe? Something like ctrl-t? My brain hurts :/[/quote]
I'm the teacher's assistant, not the teacher. Perhaps he should find a Visual Basic tutorial or even buy a book. :p
May 18, 2004, 6:10 PM
Grok
[quote author=LoRd[nK] link=board=31;threadid=6862;start=0#msg60680 date=1084903815]
[quote author=iago link=board=31;threadid=6862;start=0#msg60669 date=1084902029]
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately. I forget how to do it, but I suspect it's under the Project menu, under components maybe? Something like ctrl-t? My brain hurts :/[/quote]
I'm the teacher's assistant, not the teacher. Perhaps he should find a Visual Basic tutorial or even buy a book. :p
[/quote]

His question was either to explain how, or to give an example. Since you're unwilling to do either, you should have passed this thread by. Lately everyone on these forums thinks they are being cool by demonstrating how much they refuse to help someone who needs or wants help.
May 18, 2004, 6:29 PM
Eli_1
Forgive me for my typos :P

[code]
'/**************************************
'******Step 1: Adding The Control*******
'**************************************/

'// To create a project that uses the
'// winsock control, the first thing
'// you need to do is add the activeX
'// component to your project.

'// First click on 'Project' at
'// the top.

'// Go down to the bottom and click on
'// 'Components... Ctrl+T'
'// (It's the one right above 'Project properties...'
'// on mine).

'// A 'Components' window will popup.
'// Scroll down this list of components untill
'// you find the Winsock Control.
'// Microsoft Winsock Control 6.0 (SP5) on mine.
'// Simply check the box next to it and click 'Ok'





'/***************************************
'*****Step 2: Putting it on The Form*****
'***************************************/

'// Simply click on the winsock control on
'// the left hand side, where all the other
'// things you commonly use are -- Textbox, Label, ect...

'// The winsock control is the one with the little
'// network icon (the two little computers -- one being blue,
'// the other being green).






'/***************************************
'*******Step 3: Adding The Events********
'***************************************/

'// The easiest way to do this is to go into
'// the code window (View -> Code).

'// Once there, select what your winsock control is
'// named in the combobox (Winsock1 for this example)
'// at the top. And select the event you want to add
'// directly to the right of the name.






'/**************************************
'******Step 4: An Event Overview********
'**************************************/

'// I'll explain this one by example because
'// it's the easiest way I can think of.


Private Sub Winsock1_Error( _
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)
'// This event is self-explanitory.

'// This event will be called with the error
'// number along with a description of what happened.

'// Note: This event is raised when your ipbanned,
'// for example.
End Sub

Private Sub Winsock1_SendComplete()
'// This event will be raised when SendData returns.
'// This one isn't really that important.
End Sub

Private Sub Winsock1_SendProgress( _
ByVal bytesSent As Long, _
ByVal bytesRemaining As Long)
'// This will tell you the current progress
'// of SendData.

'// I've never used this... =/
End Sub

Private Sub Winsock1_Close()
'// This event is raised when your connection
'// is terminated.
End Sub

Private Sub Winsock1_Connect()
'// Contrary to what most beginners like to think,
'// this event is raised when your CONNECTED.

'// Example: If you were writing a bnet bot
'// using the CHAT protocol, you would
'// put your login stuff here.
End Sub

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
'// This event is raised when someone is
'// requesting to connect.

'// If you made a chat server in VB,
'// this event would be raised every time
'// a new user trys to connect to you.
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
'// Self-explanitory

'// When you receive data, this event will be raised.

'// Example:
Dim Data As String
Winsock1.GetData Data
End Sub





'/***************************************
'*****Final Step: How To Send Data*******
'***************************************/

'// Since SendData wasn't discussed in the
'// above examples, I'll put it here.

'// Note: Sending data while not connected
'// will cause an error... duh... :P

Private Function MySendData(ByVal Data As String) As Integer
'// This function will attempt to send
'// 'Data' to whatever server you're connected
'// to.

'// If no connection is currently
'// established, the function will return
'// -1 for error.

'// If the send is successful, the function
'// will return a 0.

Const SOCKET_CONNECTED As Integer = 7
If Winsock1.State <> SOCKET_CONNECTED Then
'// The socket isn't connected to anything.
MySendData = -1 '// Failure
Else
Winsock1.SendData Data
MySendData = 0 '// Success
End If

End Function

'// Useage:
'// Dim RetVal as Integer
'// RetVal = MySendData("Hello, world!" & vbCrLf)




'// With Love:
'// Eli_1
[/code]
May 18, 2004, 10:52 PM
Soul Taker
I might as well be the first to ask: why do you put the VB comments inside of C-like comments?
May 19, 2004, 12:01 AM
Eli_1
[quote author=Soul Taker link=board=31;threadid=6862;start=0#msg60740 date=1084924916]
I might as well be the first to ask: why do you put the VB comments inside of C-like comments?
[/quote]
Because I've found that C-style comments seem to stand out much more as a comment than the simple single-quote VB uses. It's just much much easier for me to read when it's like that.

Edit: I'll remove them if you want though, I'm not the one that needs to read this. So if the C-style comments there make it harder/confusing for you to read, say the word and I'll repost it.
May 19, 2004, 12:07 AM
LoRd
[quote author=Grok link=board=31;threadid=6862;start=0#msg60682 date=1084904956]
[quote author=LoRd[nK] link=board=31;threadid=6862;start=0#msg60680 date=1084903815]
[quote author=iago link=board=31;threadid=6862;start=0#msg60669 date=1084902029]
It would help if you explain how to add the winsock ocx to the project, then add the control to the form, then name it appropriately. I forget how to do it, but I suspect it's under the Project menu, under components maybe? Something like ctrl-t? My brain hurts :/[/quote]
I'm the teacher's assistant, not the teacher. Perhaps he should find a Visual Basic tutorial or even buy a book. :p
[/quote]

His question was either to explain how, or to give an example. Since you're unwilling to do either, you should have passed this thread by. Lately everyone on these forums thinks they are being cool by demonstrating how much they refuse to help someone who needs or wants help.
[/quote]
It's not as if every Winsock control function isn't covered in Visual Basic's Object Browser and help files.

Also, by using the small amount of information I provided, you could do an easy google search and be provided with endless amounts of information that are most likely more descriptive and indepth than most people on this forum, including myself, could write.

In most cases, a gentle shove in the right direction is much better in the long run than just handing out code that won't be understood.
May 19, 2004, 12:28 AM
dodge
Wow I checked this before I left and suddenly I checked it at school and 1000 people responded. For more information, I do know how to add the Winsock control, and View Code. But people are talking about "sending 0x65" and I have no idea what they mean "sending" I was working a chat thing between computers for my class incase we "couldn't talk" but then I realized it wasn't really worth it. Hope this helps a little bit... but thanks for the feedback everyone lol.

Edit:

I'm confused but here's a little guess on sending "0x65"

[code]
Winsock1.SendData 0x65
[/code]

Edit:

I found this in a forum... yeah I need to fine a site explaining this, guess an example won't help lol.

[code]
Public Sub 0x3A()
Dim dblseen as long, PacketData as string
dblseed = Val("&h" StrToHex(StrReverse(Token)))
PacketData = string(7 * 4, vbNullChar)
Result = a(PacketData, CLng(dblseed), varCDkey)
Packet.insertNonNTString PacketData
Packet.InsertNTString varUser
Packet.SendPacket &H3A
End Sub
[/code]
*Note: I added spaces so, you know, people that have a big problem with coding being all vertically lined up (me)
May 19, 2004, 4:28 PM
iago
Nobody has said anything about sending 0x65 besides you.

His instructions in that code are fairly clear - try following them. I think I've seen a chat client like you're describing on pscode.com before, but it might have been C++ (I forget).
May 19, 2004, 5:59 PM
Eli_1
[quote author=dodge link=board=31;threadid=6862;start=0#msg60815 date=1084984086]
I'm confused but here's a little guess on sending "0x65"
[code]
Winsock1.SendData 0x65
[/code]
[/quote]

No you don't literally send 0x65. 0x65 is the packet ID. You need to go on bnetdocs and figure out what packet 0x65 actually contains, and send that.

As for how to send it, most people use the PacketBuffer class.
May 19, 2004, 6:38 PM
AntiFlame
If you just want to get a bot up and running, this tutorial may be able to help out:

http://cuphead.valhallalegends.com/tutorials/lesson1.htm

If not, I suggest you go learn the basics of Winsock programming with Visual Basic. There are several good tutorials out there.

http://pscode.com/vb/scripts/ShowCode.asp?txtCodeId=30413&lngWId=1
http://pscode.com/vb/scripts/ShowCode.asp?txtCodeId=38262&lngWId=1

After you understand the basics of Winsock, you will be better able to understand the inner workings of a binary protocol. Hope that helps.
May 20, 2004, 11:16 PM

Search