Server Help

Misc User Apps - Communicating (SubGame <-> Biller)

BDwinsAlt - 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.
Code: Show/Hide

/* 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");
   }
}

CypherJF - 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.
BDwinsAlt - 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
CypherJF - 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
BDwinsAlt - Mon Jul 02, 2007 12:13 pm
Post subject:
I am still completely clueless. icon_mad.gif

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?

icon_redface.gif
Cyan~Fire - Mon Jul 02, 2007 1:09 pm
Post subject:
It's not plaintext, it's binary data.
Doc Flabby - 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
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group