Author |
Message |
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Sun Jul 01, 2007 9:46 pm Post subject: Communicating (SubGame <-> Biller) |
|
|
|
|
I'm trying to extend UBill to support subgame. I am able to send/receive datagrams. I don't know what to send or what to expect to receive. I am currently converting the biller to C and I plan on adding datagram for subgame on java as well.
When I receive a datagram it shows up as K??? where ? = the charcter used to display an unknown character.
I used an example from a website to get me started with C. I can see subgame is connecting. I have no idea what to send and what to expect to get to/from subgame.
This is the example I am using.
/* Creates a datagram server. The port
number is passed as an argument. This
server runs forever */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
void error(char *msg)
{
perror(msg);
exit(0);
}
int main(int argc, char *argv[])
{
int sock, length, fromlen, n;
struct sockaddr_in server;
struct sockaddr_in from;
char buf[1024];
if (argc < 2) {
fprintf(stderr, "ERROR, no port provided\n");
exit(0);
}
sock=socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0) error("Opening socket");
length = sizeof(server);
bzero(&server,length);
server.sin_family=AF_INET;
server.sin_addr.s_addr=INADDR_ANY;
server.sin_port=htons(atoi(argv[1]));
if (bind(sock,(struct sockaddr *)&server,length)<0)
error("binding");
fromlen = sizeof(struct sockaddr_in);
while (1) {
n = recvfrom(sock,buf,1024,0,(struct sockaddr *)&from,&fromlen);
if (n < 0) error("recvfrom");
write(1,"Received a datagram: ",21);
write(1,buf,n);
n = sendto(sock,"Got your message\n",17,
0,(struct sockaddr *)&from,fromlen);
if (n < 0) error("sendto");
}
}
|
|
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Sun Jul 01, 2007 9:52 pm Post subject: |
|
|
|
|
The VIE biller protocol hasn't been documented by anyone, I pretty much "reverse engineered" based on Catid's biller, ASSS's source code, and packet logging between subgame and subbill. _________________ Performance is often the art of cheating carefully. - James Gosling
|
|
Back to top |
|
|
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Sun Jul 01, 2007 10:20 pm Post subject: |
|
|
|
|
I don't know how I'm going to do this if that is the case. Thanks for replying.
Anyone feel like showing the subgame equivalent of the asss billing protocol.
Like... CONNECT = w/e and CONNECTOK = w/e
|
|
Back to top |
|
|
CypherJF I gargle nitroglycerin
Gender: Joined: Aug 14 2003 Posts: 2582 Location: USA Offline
|
Posted: Mon Jul 02, 2007 7:13 am Post subject: |
|
|
|
|
Well, it uses the VIE core protocol, the first packet you should receive from Subgame would look like
00 01 RR RR RR RR 00 01
Where those numbers are hex values, and RR is a byte of a 4-byte little endian integer.
You can read more about the VIE protocol here:
http://mervbot.com/files/addendum.txt
|
|
Back to top |
|
|
BDwinsAlt Agurus's Posse
Age:33 Gender: Joined: Jun 16 2003 Posts: 1145 Location: Alabama Offline
|
Posted: Mon Jul 02, 2007 12:13 pm Post subject: |
|
|
|
|
I am still completely clueless.
Subgame only sends me stuff like this.
I don't understand how to send those 01 02 RR RR KK VV things. ASSS always sent plain text. This is all new to me. How do I send and decode things sent from subgame?
Screenshot-1.png - 44.71 KB
File downloaded or viewed 33 time(s)
|
|
Back to top |
|
|
Cyan~Fire I'll count you!
Age:36 Gender: Joined: Jul 14 2003 Posts: 4608 Location: A Dream Offline
|
Posted: Mon Jul 02, 2007 1:09 pm Post subject: |
|
|
|
|
It's not plaintext, it's binary data. _________________ This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
|
|
Back to top |
|
|
Doc Flabby Server Help Squatter
Joined: Feb 26 2006 Posts: 636 Offline
|
Posted: Tue Jul 03, 2007 5:34 am Post subject: |
|
|
|
|
You will struggle with processing the binary data in java, as java uses big-endian and subgame uses small endian.
The TCP-Billing protocol is an order of magnitude simpler (it was designed to be simpler) than the VIE-billing protocol. It is also very much "c" orientrated, it is based on "stucts" To use it (in c) you need to create a struct of each data packet. then cast the received packet into the correct struct. however some datapackets can contain other packets inside them.
There is a good helper java class in twcore for processing subgame binary data. You may wish to look at the code for my semi-working dir-server (uses core protocal) http://forums.minegoboom.com/viewtopic.php?t=7149 _________________ Rediscover online gaming. Get Subspace | STF The future...prehaps
|
|
Back to top |
|
|
|