FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

raknet
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> Bindings
View previous topic :: View next topic  
Author Message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Sat Nov 19, 2005 11:01 am    Post subject: raknet Reply with quote

I've created a binding for the C++ library Raknet.
www.rakkarsoft.com

I'm not going to commit them just yet, but if anyone wants a head start on getting raknet working for D, look here --> http://svn.dsource.org/projects/warbots/trunk/cinterface/

chat.d, lineserver.d, and line.d all work as advertised. Before I commit I'll make sure it works on windows and I might whip up some ddoc's.

Note that I havn't exposed the whole raknet interface, only the parts that I want to use. I'll add more as I need. If anyone has any requests for exposed functionality just ask here, and I'll whip them in.
Back to top
View user's profile Send private message AIM Address
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Wed Nov 23, 2005 10:46 pm    Post subject: Reply with quote

Well, I've since learned that it is currently impossible to get the raknet bindings to work with windows due to linker issues. Somebody please prove me wrong Smile

Linux users, get your raknet bindings here --> http://svn.dsource.org/projects/bindings/trunk/raknet/

Some mighty windows programmer, get raknet to work on windows Wink
Back to top
View user's profile Send private message AIM Address
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Wed Nov 23, 2005 11:48 pm    Post subject: Reply with quote

I'm no mighty windows programmer, but I'm very curious to figure out what's going on here. I've struggled with similar problems with dmc several times before over that last few years (huge amounts of annoyance; sometimes solved, sometimes not).

Maybe I can fiddle with it and see what's going on. No promises, though. Honestly, I don't know why I'm doing this to myself: I'm likely to start banging my head on my keyboard in frustration.... I can see it coming again... Shocked

-JJR
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Nov 24, 2005 2:15 am    Post subject: Reply with quote

clayasaurus wrote:
Well, I've since learned that it is currently impossible to get the raknet bindings to work with windows due to linker issues. Somebody please prove me wrong Smile


Mike84 from the Damage project did it Smile I was a tester. Works Razz
Back to top
View user's profile Send private message MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Nov 24, 2005 3:43 am    Post subject: Reply with quote

Hmmm... I never had a close look at the damage project. It seems to have no listing in the project tab anymore.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Nov 24, 2005 5:25 am    Post subject: Reply with quote

It's not listed... but it's there Very Happy /+ some sort of magic maybe +/
http://www.dsource.org/projects/damage/
Back to top
View user's profile Send private message MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Nov 24, 2005 11:51 am    Post subject: Reply with quote

Yeah, I saw it when you first pointed it out. I was just a little surprised that it was hidden. Maybe Brad can get it linked up again.

It's too bad Mike84 doesn't have any source in the trunk section. It would make the code much easier to browse. Having to download the large archived files (like source.tar) with dialup is a bit of a pain.

It's good to see that he's got raknet working on windows, though. I had already started trying to get dmc and tools working with Clay's port. I've got exactly two symbol conflicts in the link process now. I think it's the way Clay has the C++ set up. I don't think dmc likes it. Acutally, dmc goes into contortions on the regular raknet code. I was surprised at how much code I had to change to get it to progress through the code. (this was while I was experimenting in trying to compile the whole C++ RakNet project with dmc; didn't get too far yet) Razz

With Clay's rakglue source:

For example, each rakglue/*.h file includes the raknet/include/networktypes.h file. When you compile each rakglue/*.cpp file, it appears that you are including separate instances of the global PlayerID struct constant, UNASSIGNED_PLAYER_ID. I have no idea how to make dmc see it as a single instance so that the lib command doesn't pull it in 3 times, once for each object file. Also the "extern" directive in rakglue on the dataStream variable doesn't see to do the job. The linker can't see it when I try to compile chat.d.

We'll see how Mike84 did it. It's likely that he's saved me a huge amount of trouble. Smile

-JJR
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Nov 24, 2005 12:01 pm    Post subject: Reply with quote

JJR wrote:
It's too bad Mike84 doesn't have any source in the trunk section. It would make the code much easier to browse. Having to download the large archived files (like source.tar) with dialup is a bit of a pain.


Yup... but he's not working on the project. He was looking for someone to pick up where he'd left the code. IIRC he was too busy due to some college stuff.

Quote:
I was surprised at how much code I had to change to get it to progress through the code. (this was while I was experimenting in trying to compile the whole C++ RakNet project with dmc; didn't get too far yet) Razz


Isn't it why we all love C++ so much ? Laughing


Quote:
We'll see how Mike84 did it. It's likely that he's saved me a huge amount of trouble. Smile


IIRC, he's done a simple wrapper DLL using Visual Studio. He then loads just one function from it. The function in turn returns a struct which contains all the needed function pointers to C wrapper functions over the C++ interface...
Back to top
View user's profile Send private message MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Nov 24, 2005 1:07 pm    Post subject: Reply with quote

Yeah... I see how he did it now. It's deceptively simple. He basically added a file to the original RakNet source that includes a single exported C function. This function, getAPI, is compiled into the RakNet.dll as __declspec(dllexport), and is therefore loadable by a D program. getAPI initializes a struct that contains pointers to all the wrapped functions in that source file (main.cpp). Build the RakNet project with Visual C++ and voila! The D program just has to load the single function from the DLL.

His method is simple and effective. It's a good method to remember for future ports.

Clay, Mike84 has done all the hard work for you (and me). Wink

-JJR
Back to top
View user's profile Send private message
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Thu Nov 24, 2005 1:14 pm    Post subject: Reply with quote

h3r3tic wrote:
Quote:
I was surprised at how much code I had to change to get it to progress through the code. (this was while I was experimenting in trying to compile the whole C++ RakNet project with dmc; didn't get too far yet) Razz


Isn't it why we all love C++ so much ? Laughing


Shocked

You can say that again!!! I can't stand it! There are so many inter-compiler differences, I don't know how C++ has survived. It's absolutely, positively disgusting. The templates were such an eyesore in RakNet, I almost went blind! Death to C++! Confused

-JJR
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Thu Nov 24, 2005 11:47 pm    Post subject: Reply with quote

Two things I don't understand about mike's port...

1) It doesn't define PlayerID
2) Packet is align( 8 ), why is that? *confused*

anyway, hopefully my playerID works with it
Back to top
View user's profile Send private message AIM Address
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Fri Nov 25, 2005 12:16 am    Post subject: Reply with quote

1) PlayerID was hard to find. It's defined in shared/s_shared.d:

Code:

align(8) struct PlayerID
{
    uint binaryAddress;
    ushort port;
}


2) I don't know about Packet. I believe it means align the structure members at 8 byte (64 bit) boundaries.

I'm not sure why this is necessary, but perhaps mike found that the connection to RakNet didn't work without this alignment. Perhaps it was necessary to match the default alignment of Visual C++ builds. If the RakNet library had been built with DMC, I doubt that this explicit alignment would be necessary.

I was looking at your playerID earlier. I'm not so sure it will work. At the very least, it's probably wise to remove the operator overloads for now. They shouldn't be needed external to the library anyway. That's the safe thing to do, I guess.

-JJR
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Fri Nov 25, 2005 5:33 am    Post subject: Reply with quote

JJR wrote:
Death to C++! Confused

Wow ! Now that sounds great ! I visualize a furious D programmer in a silver medieval armor striking his evil C++ opponents with a new shiny DMD version Laughing /+ I aint sick +/


/+ I'm sure Mike would answer any doubts regarding the align ( 8 ) /+ or anything else +/ if PM'ed Razz +/
Back to top
View user's profile Send private message MSN Messenger
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Fri Nov 25, 2005 11:27 am    Post subject: Reply with quote

Heh... well, I have to apologize. My words may have sounded a little extremist. Mostly I was just venting after playing with a little too much C++. Apparently, it was a shock to my system to try my hand at it again. Confused

Crusader or not, conversion by force isn't a solution. Wink

-JJR
Back to top
View user's profile Send private message
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Fri Nov 25, 2005 5:13 pm    Post subject: Reply with quote

No, we'll have to make do with conversion by subversion Wink Seriously, though, just getting the word out about D is enough. If people are sick of C++ and want a better alternative and know about D, chances are they will start coding in D.

----------------

I got my bindings to work with windows. *hurrahh* I also got my windows box to connect to my linux box with raknet, with my super advanced opengl networked line drawing program : )

I added my hacked windows raknet sources and the linux sources I used and my raknet.lib and raknet.a files. This is so when new versions come out and don't work with these bindings you just grab the sources from here instead, until someone wants to have a go with C++ again or Rakkar decides to support DMC.

Happy networking Smile

~ Clay
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Bindings All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group