Author | Message | Time |
---|---|---|
Mephisto | Does anyone know where I might attain a sample BNLS client coded in C/C++? Or perhaps an open source bot which uses BNLS (C/C++; not VB, thanks). | October 5, 2004, 2:33 AM |
Spht | [quote author=Mephisto link=topic=9017.msg83292#msg83292 date=1096943608]Does anyone know where I might attain a sample BNLS client coded in C/C++?[/quote] Skywing wrote SNLS with VC++ 7. It's "a simple demonstration of using BNLS's SNLS functions to check NLS style logins." Is that the kind of thing you were looking for? [quote author=Mephisto link=topic=9017.msg83292#msg83292 date=1096943608]Or perhaps an open source bot which uses BNLS (C/C++; not VB, thanks). [/quote] Not that I know of. The protocol is fairly uncomplicated and well documented, so I doubt anyone bothered to publish their source code for it. | October 5, 2004, 2:45 AM |
Mephisto | Well, I began working on the connection to BNLS, but I ran into some problems after sending packet 0x01; BNLS wasn't responding. I'm guessing it's some minor error, which is why I wanted to look through some source code. SNLS would probably be good if I could view the source code to it, but I doubt the source will ever become avaliable. | October 5, 2004, 3:11 AM |
drivehappy | I don't know if you saw this or not, but it might be the problem: https://davnit.net/bnet/vL/phpbbs/index.php?topic=8988.0 | October 5, 2004, 4:55 AM |
KkBlazekK | [quote author=drivehappy link=topic=9017.msg83308#msg83308 date=1096952122] I don't know if you saw this or not, but it might be the problem: https://davnit.net/bnet/vL/phpbbs/index.php?topic=8988.0 [/quote] That problem occured due to the bnls server he was connecting to was down. | October 5, 2004, 4:07 PM |
UserLoser. | [quote author=Mephisto link=topic=9017.msg83296#msg83296 date=1096945895] Well, I began working on the connection to BNLS, but I ran into some problems after sending packet 0x01; BNLS wasn't responding. I'm guessing it's some minor error, which is why I wanted to look through some source code. SNLS would probably be good if I could view the source code to it, but I doubt the source will ever become avaliable. [/quote] Show some code, maybe you're doing recv wrong or your client was/is totally confused and BNLS was actually responding | October 5, 2004, 6:42 PM |
Mephisto | [code] while (connected) { int buflen = 0; int recvlen = recv(s, buffer + buflen, sizeof(buffer) - buflen, 0); if (!recvlen || recvlen == SOCKET_ERROR) { cout << "BNLS has closed the connected!" << endl; cout << "Exiting..." << endl; Sleep(1000); } buflen += recvlen; while ((int)buflen >= 3 && connected) { packetid = buffer[2]; packetlen = *(unsigned short *)(buffer + 0); memcpy(packetdata, buffer, packetlen); switch(packetid) { case 0x01: cout << "Received packet 0x01 from BNLS!" << endl; break; } } }[/code] The Sleep() call was for debugging...And I know it's sending the packet to BNLS/connected because send works. | October 5, 2004, 9:03 PM |
UserLoser. | Is recvlen ever 0, or does it ever print "BNLS has closed the connected!"? Btw, at the end of your while loop you should put a message loop so it doesn't eat up your cpu usage. Instead of Sleep(1000), you could put getch(), which'll wait until the user hits a key | October 5, 2004, 9:39 PM |
kamakazie | Looks like buflen is being reset to 0 each iteration of the first while loop thereby overwriting your buffer everytime you recv. | October 5, 2004, 9:49 PM |
Mephisto | [quote author=dxoigmn link=topic=9017.msg83393#msg83393 date=1097012952] Looks like buflen is being reset to 0 each iteration of the first while loop thereby overwriting your buffer everytime you recv. [/quote] Isn't that the point? You don't want to keep the old data when you receive new data. If you wanted this you could always store it somewhere before the loop reiterates. | October 5, 2004, 9:59 PM |
kamakazie | [quote author=Mephisto link=topic=9017.msg83394#msg83394 date=1097013562] [quote author=dxoigmn link=topic=9017.msg83393#msg83393 date=1097012952] Looks like buflen is being reset to 0 each iteration of the first while loop thereby overwriting your buffer everytime you recv. [/quote] Isn't that the point? You don't want to keep the old data when you receive new data. If you wanted this you could always store it somewhere before the loop reiterates. [/quote] Then what is the point of buflen? It will always equal 0 or recvlen. So basically you're code can be condensed into: [code] while (connected) { int recvlen = recv(s, buffer, sizeof(buffer), 0); if (!recvlen || recvlen == SOCKET_ERROR) { cout << "BNLS has closed the connected!" << endl; cout << "Exiting..." << endl; Sleep(1000); } while ((int)recvlen >= 3 && connected) { packetid = buffer[2]; packetlen = *(unsigned short *)(buffer + 0); memcpy(packetdata, buffer, packetlen); switch(packetid) { case 0x01: cout << "Received packet 0x01 from BNLS!" << endl; break; } } } [/code] Do you see what I'm trying to get at now? The above code doesn't seem useful at all yet that is exactly what you're orginal code is doing. If you were to move int buflen = 0 out of the first while, then you're code should work. However, you need to decrement buflen by the length of data you parse in your switch. Edit: Also, make sure buflen >= packetlen in that second while loop before doing that memcpy. | October 5, 2004, 11:11 PM |
Mephisto | Yes, thank you. | October 5, 2004, 11:15 PM |