Advertisement

Enet - how can I work with this thing?

Started by August 12, 2004 04:32 AM
5 comments, last by Sneftel 20 years, 6 months ago
Note: Skip the first segment of this post if you like as reflects a ‘life story’ etc Hello… Previously I have coded a half-complete DirectPlay networking engine of which I intended to use in my current project (2d multiplayer action game). However, I hear that DirectPlay is now outdated and discontinued by Microsoft. I do not wish to dive head-over-heals into Winsock because I have limited time on my hands – time that I’d rather spend programming the elements of my game. Upon a little searching, I have come across several options, all with their drawbacks and limitations ( Raknet – one time only use etc etc ). Anyhow, I have decided to give Enet a good look – I know the basics of multiplayer programming and client/server communication and still want the freedom to learn. Enet, a low-level socket wrapper, seems solid and entirely appropriate. However, upon downloading Enet, I am presented with a net of header and c source files that don’t seem connected properly. I have tried for some time to get this thing working via MSVC++ – building as a lib, including directly into my project, messing around with the source code a little etc – and am yet to achive any success. The problem is that I am used to using APIs such as DirectX upon where instillation is rather simple. At this point I simply do not know how to install and use Enet within a project… Can anyone help me with this? Has anyone here used Enet? A list of instructions would be so much help… Thanks, Jackson Allan
Why not use WinSock? It always helped me out!
GBS
Advertisement
Quote:
Original post by jack_1313
I do not wish to dive head-over-heals into Winsock because I have limited time on my hands – time that I’d rather spend programming the elements of my game.


I think that just about answers your question? :)
Anyhow, if I can avoid the gritty stuff I can spend my time doing more productive things. Also, given that I learn entirely from trial-and-error / internet there is the thought that any Winsock code I write may be bugged beyond help. If I can use a low-level wrapper things will become much simpler.

Which reminds me... I only have a single computer to work with (but will be able to test now and them via modem connection with associates) - will this prove a major issue?
Found the error… turns out I was on the right track anyhow. It seems that after building Enet as a library and adding it to your project (including enet.h as you do) you must also include the provided win32.h and win32.c within your workspace (above your inclusion of enet.h).
The extra includes are, for some odd reason, not mentioned anywhere in the documentation despite the fact that it is a known issue with MSVC++.
Also note in future that it be neccissary that you #define _WINSOCKAPI_ before including windows.h in your projects that make use of Enet. This is not addressed in the documentation either. All cleared up…

Which leads me to ask – will I be able to create fast-action multiplayer games primarily using a single computer? Or is that out of the question?
> will I be able {...} using a single computer?

Yes. Just initialize two game instances with different port numbers. The packets will bounce in the driver back to the other instance and never reach the net.

-cb
Quote:
Original post by cbenoi1
> will I be able {...} using a single computer?

Yes. Just initialize two game instances with different port numbers. The packets will bounce in the driver back to the other instance and never reach the net.

-cb


Yes, that is what I have been doing... but in order to adequately test the game I will need to simulate net conditions - many players, unpredictable packet loss, time stamping and lag issues. My idea is to send my messages to a 'lag' program, which stalls the packets for some time before forwarding them to their destination, occasionally deleting a packet etc. I intend to substitute real players (usually unavailable) with AI bot clients for testing purposes. Does this sound ok?

On a side not: thumbs up for Enet - very easy and efficient to use once you get it working...
Advertisement
I'm pretty sure that there are specialized network drivers out there that will do that for you, adding latency and randomly dropping UDP packets. Google around and you should find stuff.

This topic is closed to new replies.

Advertisement