Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sat Dec 16, 2017 1:38 am

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Networking. (YASD)
PostPosted: Mon Mar 06, 2006 6:01 pm 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
Networking demo. (Yet Another Simple Demo)

  • The server will open port 4000
  • The client will connect to port 4000
  • The server sends a nice message to the client
  • The client displays the message on the console
  • Both programs terminate :D

And best of all: sources are included and it runs both on Linux and Windows.

To compile with MinGW on windows:

g++ -o client.exe client.cpp -lws2_32
g++ -o server.exe server.cpp -lws2_32

To compile on linux:

g++ -o client client.cpp
g++ -o server server.cpp

Enjoy. :)

Why is this usefull? Let's see:
  • Activity! There hasn't been any for months.
  • Cross platform!
  • The networking threshold is crossed, so we'll never have to look at this problem again.


Attachments:
File comment: If you know what to do: compile your own binaries.

If you have no clue: run the .exe files FROM A CONSOLE!

network.zip [250.51 KiB]
Downloaded 320 times

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)
Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+

[ General TE Discussion ] [ TE Development ] [ TE Coding ]
Under construction...
Top
   
 Post subject:
PostPosted: Mon Mar 06, 2006 9:22 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Mon Jun 09, 2003 6:21 pm
Posts: 4532
Location: /home/sweden
Thanks for breaking the silence. :)

I'd played a bit with the code, but nothing advanced.

_________________
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)


Top
   
 Post subject:
PostPosted: Mon Mar 06, 2006 10:40 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Dec 03, 2002 10:36 am
Posts: 13161
Location: The Netherlands
Indeed worth a BIG thanks, Hellfire. I think I fall into the category who will run the exe from a console ;).

_________________
Image
Dutch Trainset for OpenTTD | Dutch Trainset Topic | Combined Roadset v0.10


Top
   
 Post subject: Re: Networking. (YASD)
PostPosted: Wed Mar 08, 2006 7:23 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Fri Oct 03, 2003 11:59 pm
Posts: 1429
Location: Lancashire, UK
Hellfire wrote:
Networking demo. (Yet Another Simple Demo)

  • The server will open port 4000
  • The client will connect to port 4000
  • The server sends a nice message to the client
  • The client displays the message on the console
  • Both programs terminate :D

And best of all: sources are included and it runs both on Linux and Windows.

Am I right in saying that this is only if you have MinGW?
If so, this is a great thing to get the project back on track ;), but I would think that we'll have to take out the MinGW dependency asap.
If not, klasse!

_________________
Image
You're saying I'm a Dominion spy, and don't even know it! - Dr. Bashir
That's the Joker in my avatar, not me. No wait it is me.


Top
   
 Post subject:
PostPosted: Thu Mar 09, 2006 5:59 am 
Offline
Transport Empire Developer
Transport Empire Developer
User avatar

Joined: Mon Feb 03, 2003 9:30 am
Posts: 699
Location: Back at the office
DominionSpy wrote:
Am I right in saying that this is only if you have MinGW?
If so, this is a great thing to get the project back on track ;), but I would think that we'll have to take out the MinGW dependency asap.
If not, klasse!

I'm not sure. I've compiled it with MinGW, but I think it will work with MS Visual C++ or some Borland equivalent as well. It might need a few changes but those are just minor things.

In fact, I had to do some strange things to get the networking support to work on both Linux and Windows:

Code:
#ifdef WIN32
  #include <winsock2.h>
#else
  #include <sys/sockets.h>
  #include <arpa/inet.h>

etc.

(Yes, MinGW needs Winsock for IP support...)

_________________
Feel free to contact me over Email! My current timezone: Europe/Amsterdam (GMT+1 or GMT+2)

Code:
+------------Oo.------+
| Transport Empire -> |
+---------------------+


[ General TE Discussion ] [ TE Development ] [ TE Coding ]

Under construction...


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.