Advertisement

Will Winsock work if my game is opened in a DOS window?

Started by January 27, 2001 11:47 PM
4 comments, last by IronFist 23 years, 10 months ago
My game uses Allegro for it''s graphics and I''m using DJGPP for the compiler. When I click on the icon, it opens the game in a DOS window. I am wondering if Winsock would work with this or if I have to learn DOS networking (ugh! ) I know that I could use the Allegro WIP, and use DirectX, but I don''t want to use DirectX. I want my game to be usable on all dos based computers. I don''t want it so the player has to have DirectX on his/her computer to play.
Play Sumasshu, which is a game I programmed. CLICK HERE
No, obviously WinSock is only for Windows, not DOS. But then, why are you writing a game in DOS anyway? Ask anyone you like, and they will tell you that DOS games suck (no offense) in a Windows environment because you have to mess around with 640k limits, non-existing drivers, mouse emulation and more...

If the DirectX issue is really a problem, use LibSDL! It''s basically a wrapper around lots of different gfx APIs. On Windows it''ll use DX if available (and who doesn''t have DX these days anyway), but it will fallback to GDI if it isn''t. Plus, with SDL it''s sooo easy to port to other OSs like Linux.

cu,
Prefect

---
Sanity is the trademark of a weak mind.
Widelands - laid back, free software strategy
Advertisement
I did more reading about Allegro and DirectX, and I figured out that the person doesn''t have to have direct X installed, they just have to have a couple DLLs that I can send with my game. So I am now in the process of installing the Allegro WIP to work with MVC++ (wish me luck ).
Play Sumasshu, which is a game I programmed. CLICK HERE
Just for the sake of posting, I''d like to say that if it''s a Win32 console app, it''s easy to use Winsock. Just create the window like you normally would, but don''t show it. This probably doesn''t apply, since he was using DJGPP, but it''s something a lot of people overlook.
If you want to use Winsock from your DOS based game - you will have to do a few things - and let me preface this by say that I haven''t tried this and I am not 100% sure that this will work.

1) Include these files
#include
#include or depending on if you are using the features of Winsock 2.

This requirement is also dependent on the compiler that you are using. If you are using a compiler that can''t generate Win32 exe''s then I can safely say that this will not work.

As I have never used the DJGPP compiler I can''t comment.

But let''s assume that you can compile win32 exe''s and that those two files are included and that you are linking with the correct winsock dll -

You can use Winsock from console based applications... it is a little tricker than coding a Windows GUI client, as you are not programming in the event model. You will have to rely on event objects and placing your network coding into the game loop.

One thing that I might add- from my experience if you have not planned for multi player operations, then don''t add them to an existing game - my experience and all of the reading that I have done will tell you that it is harder to retrofit the game to use networking than to create a game with this as a planed option or part of the final game.

If you want some advice on coding Winsock using event objects, I think there is a new article here on gamedev that can help get you started. I myself am writing an article covering this issue. I can send you a link to the incomplete version, if you like.

Game On,

Dave "Dak Lozar" Loeser
Dave Dak Lozar Loeser
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."--anonymous
It is _possible_ to use WinSock via DJGPP...you might want to check out libsocket.

==================
/* todo: insert cool sig */
Martee
Magnum Games.NET
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

This topic is closed to new replies.

Advertisement