Sign in to follow this  

Torrent API for Web-based game installer.

This topic is 2341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello :).

I am developing a video game ([url="http://img10.imageshack.us/img10/2011/gvrainforest.jpg"]screenshot[/url]), and have developed a web-based installer for it:
[url="http://img195.imageshack.us/img195/5013/installerss.jpg"][img]http://img195.imageshack.us/img195/5013/installerss.th.jpg[/img][/url]

It currently uses libCURL to to download the game-data from HTTP/FTP sources. Because of the demand on servers, I am looking into adding p2p torrent support. [b]Does anyone know of a good, bittorrent implementation?[/b] Preferably written in C and cross-platform with webseed support. A library that implements everything would be great if someone knows of one, but if none exist does anyone know a good torrent-protocol tutorial?

Thanks beforehand :).

Share this post


Link to post
Share on other sites
Just make sure to have it disabled by default and be completely optional.

With increased data caps you can break user's data cap and incur extra costs.

Bit torrent also has bad reputation and large number of connections can trigger various alerts.

I won't say this is the biggest problem, but so far Blizzard is the only one I can recall using BT and they might get privileged treatment.

[quote] Because of the demand on servers[/quote]

What kind of servers and how much traffic? How do AppEngine or S3 prices compare to that?

Share this post


Link to post
Share on other sites
Antheus: Thanks for your reply. There has been a lot of thought put into this, and BitTorrent is the best option for Galactic Vice :). I am also not too concerned about the potential problems BitTorrent may present, as users would be able to disable if if necessary.

Does anyone know of an alternative to libtorrent, one that doesn't boost?

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1310950544' post='4836563']
Out of sheer curiosity, why don't you like Boost? It's basically a waiting-room for the next C++ standard library [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]
[/quote]
Well, I don't want to start a debate or anything, but I am a die-hard Scheme/C fan (that should say it all :D). IMHO C++ (and especially Boost), implement very bad programming techniques. Yes, programming in a low-level language is hard and meticulous for those used to high-level programming, but it uses a completely different coding mindset/technique that once mastered is far easier than the high-level programming. It allows for cross-platform, screaming-fast, and minimalistic/non-bloated programs to be written with elegant simplism.

On the other hand, C++ often leads to code like this:
[code]#include <stdio.h>

enum { SCALElog=15, SCALE=1<<SCALElog, mSCALE=SCALE-1, hSCALE=SCALE/2 };

template< int DECODE >
struct Rangecoder {
enum { NUM=4, sTOP=0x01000000U, Thres=0xFF000000U };

typedef unsigned long long int qword;
unsigned range, code, FFNum, Cache; qword lowc; FILE* f;

void Init( FILE* _f ) {
f = _f; range = 0xFFFFFFFF; lowc = 0; FFNum = 0; Cache = 0;
if( DECODE==1 ) for( unsigned _=0; _<NUM+1; _++ ) (code<<=8)+=getc(f);
}

void Quit( void ) { if( DECODE==0 ) for( unsigned _=0; _<NUM+1; _++ ) ShiftLow(); }

unsigned Process( unsigned freq, unsigned bit ) {
unsigned rnew = (qword(range)*(freq<<(32-SCALElog)))>>32;
if( DECODE ) bit = (code>=rnew);
bit ? range-=rnew, (DECODE ? code-=rnew : lowc+=rnew) : range=rnew;
while( range<sTOP ) range<<=8, (DECODE ? (code<<=8)+=getc(f) : ShiftLow());
return bit;
}

unsigned ShiftLow( void ) {
unsigned Carry = unsigned(lowc>>32), low = unsigned(lowc);
if( low<Thres || Carry ) {
putc( Cache+Carry, f );
for (;FFNum != 0;FFNum--) putc( Carry-1, f );
Cache = low>>24;
} else FFNum++;
return lowc = (low<<8);
}
};

struct Predictor {
short cxt;
short p[256-1];

Predictor() { for( unsigned i=0; i<sizeof(p)/sizeof(p[0]); i++ ) p[i]=hSCALE; byte(); }
int P() const { return p[cxt-1]; }
unsigned byte( void ) { unsigned c=cxt; cxt=1; return c; }

void update( unsigned y ) {
if( y ) p[cxt-1] -= ( p[cxt-1] >> 5), cxt+=cxt+1;
else p[cxt-1] += ((SCALE - p[cxt-1]) >> 5), cxt+=cxt+0;
}
};

template< class Predictor, class Rangecoder >
void proc( Predictor& p, Rangecoder& rc, unsigned y=0 ) { p.update( rc.Process( p.P(), y ) ); }

unsigned flen( FILE* f ) {
fseek( f, 0, SEEK_END );
unsigned len = ftell(f);
fseek( f, 0, SEEK_SET );
return len;
}

int main( int argc, char** argv ) {
unsigned i,c,f_len = 0;
if( argc<4 ) return 1;
FILE* f = fopen( argv[2], "rb" ); if( f==0 ) return 2;
FILE* g = fopen( argv[3], "wb" ); if( g==0 ) return 3;
Predictor p;
if( argv[1][0]=='c' ) {
f_len = flen( f );
fwrite( &f_len, 1,4, g );
Rangecoder<0> rc; rc.Init(g);
for( i=0; i<f_len; i++ ) {
c = getc(f); p.byte();
proc(p,rc,c&0x80); proc(p,rc,c&0x40); proc(p,rc,c&0x20); proc(p,rc,c&0x10);
proc(p,rc,c&0x08); proc(p,rc,c&0x04); proc(p,rc,c&0x02); proc(p,rc,c&0x01);
} rc.Quit();
} else {
fread( &f_len, 1,4, f );
Rangecoder<1> rc; rc.Init(f);
for( i=0; i<f_len; i++ ) {
proc(p,rc); proc(p,rc); proc(p,rc); proc(p,rc); proc(p,rc); proc(p,rc); proc(p,rc); proc(p,rc);
putc( p.byte(), g );
}
}
fclose( f );
fclose( g );
return 0;
}[/code]

Yes, that's a range coder. Yes, It's horribly slow. And yes, I think I just went blind xD.

[b]
Back to the original topic:[/b] Does anyone know of an alternative to libtorrent, one that doesn't boost?

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1310964416' post='4836639']
Well...

I think that's an absolutely worthless argument with so many holes it makes a block of Swiss cheese jealous; but I won't hijack your thread into a debate about boost unless you really want to.
[/quote]
Please, lets not. Lets continue this in a PM :).

Share this post


Link to post
Share on other sites
[quote name='Conoktra' timestamp='1310961087' post='4836628']
Yes, that's a range coder. Yes, It's horribly slow. And yes, I think I just went blind xD. [/quote]

The funniest thing is, that is C code, not C++. It's just wrapped into a class.

Share this post


Link to post
Share on other sites
[quote name='Antheus' timestamp='1310998547' post='4836816']
The funniest thing is, that is C code, not C++. It's just wrapped into a class.
[/quote]
Ok, well, if it really is just "C code" then I challenge you to get it to compile with GCC in strict-ANSI mode (-ansi).

Share this post


Link to post
Share on other sites
I like how you completely ignored the part where he said it's been mangled into class form, then try to misinterpret his statement and get all blustery over it.

The point is, the code you posted is [i]shit[/i], and hardly representative of idiomatic, clean C++. So your argument is borked.

Share this post


Link to post
Share on other sites
[quote name='ApochPiQ' timestamp='1311015958' post='4836953']
I like how you completely ignored the part where he said it's been mangled into class form, then try to misinterpret his statement and get all blustery over it.

The point is, the code you posted is [i]shit[/i], and hardly representative of idiomatic, clean C++. So your argument is borked.
[/quote]
I am sorry, but I don't appreciate flaming. (Who do I contact for mis-behaving forum moderators?) Like I said, I don't want to get into a debate. You asked for my oppinion and I gave it too you--now let it go.

EDIT: I found the contact.

Share this post


Link to post
Share on other sites
Just wanted to publicly note that my posts here were the result of some poor coping mechanisms with a high-stress week. I won't pretend like that excuses my behavior but at least I'd like my forum-peeps to know what's going on. My post was totally out of character and really uncalled-for and I hope that you guys can cut me a break for lashing out after a rough day.

I've apologized in detail to Conoktra via PM, and thanked him for calling me out on this. I appreciate that he did the right thing here, and I would like to encourage anyone else who has concerns about the actions of myself (or any of the staff) to do the same. That's how we keep this place the great community that it is.


Carry on [img]http://public.gamedev.net/public/style_emoticons/default/smile.gif[/img]

Share this post


Link to post
Share on other sites

This topic is 2341 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this