Simple enet server/client

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Simple enet server/client

Postby 1000101 » Sep 22, 2006 3:40

For those who don't know, enet is a simple network packet delivery system which offers garunteed delivery without the overhead of TCP. While TCP and enet provide the same basic functionality, the enet protocol is better for games in that the data being transfered is a bit lighter and more streamlined, thus allowing more packets to be delivered in a given timeframe.

Anyway, this is a simple sample showing connecting a client to a server and exchanging some simple information. In this case a text message each way. The client prompts the user for the text to send to the server and the server responds with a pre-formulated string and a random number.

http://ecowles.dyndns.org/download.php? ... xample.rar

Note: The provided executable is a Win32 executable which will attempt to contact my server. My server will be left running until I end up shutting it down or it crashes, which-ever comes first. You can rebuild the client/server for linux but you need to build enet for linux (http://enet.cubik.org/). There is no DOS port [period].
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Postby Ryan » Sep 22, 2006 4:32

Very nice. Even got my very own random number. I'll have to look into this for game building... I love MUD style games, so I'm curious if something like this would be able to communicate w/ Telnet or if it's a totally different animal.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Sep 22, 2006 4:49

telnet uses TCP I believe which enet is not compatable with. enet is it's own protocol and can only communicate via enet.

Oh, and I changed my server to send verses from a song. Much amusement to be had!
arenth
Posts: 511
Joined: Aug 30, 2005 6:22

Postby arenth » Sep 22, 2006 15:22

telnet uses TCP I believe which enet is not compatable with. enet is it's own protocol and can only communicate via enet.

Oh, and I changed my server to send verses from a song. Much amusement to be had!


You'd be right about telnet, and TCP in general, TCP apps will not work with enet, neither will straight UDP apps.Enet is pretty well only compatible with enet, much like SDL_net is only compatible with SDL_net (I was incorrect, apparently SDL_net is fully TCP/IP and UDP compliant).

Your also right about the amusement to be had from your server. Though I'm not sure of the song, banana ping pong certainly has much amusement.
Last edited by arenth on Sep 22, 2006 17:15, edited 1 time in total.
Ryan
Posts: 695
Joined: Jun 10, 2005 2:13
Location: Louisville, KY
Contact:

Postby Ryan » Sep 22, 2006 15:56

Sounds like using enet for a game server would then eliminate the checking I would have to do to prevent someone screwing it up with a telnet client. I just might get to resurrect an old project of mine with this.. : P
yetifoot
Posts: 1710
Joined: Sep 11, 2005 7:08
Location: England
Contact:

Postby yetifoot » Sep 22, 2006 16:06

Arenth: Why do you say SDL_Net only compatible with SDL_Net?

I used it to make TCP connections to an IRC server sucessfully, it seems fully UDP/TCP compliant.
arenth
Posts: 511
Joined: Aug 30, 2005 6:22

Postby arenth » Sep 22, 2006 17:14

Oh ok then, I stand corrected. I could have sworn SDL_net was only compatible with SDL_net.
1000101
Posts: 2556
Joined: Jun 13, 2005 23:14
Location: SK, Canada

Postby 1000101 » Sep 23, 2006 1:26

arenth, what I meant was that telnet uses TCP and not UDP. Theoretically if it used UDP, you could write a packet driver for telnet to use the enet protocol but, it doesn't so you can't.

Also, rebuilt and have the client/server using the release build of enet.

The lyrics are from the song "Banana Phone." It's quite an amusing song.

http://en.wikipedia.org/wiki/Bananaphone

The last link in the "External links" section is a HL2 animation with the original CD music. Very funny.
jdmcbride
Posts: 27
Joined: Aug 06, 2016 16:13

Re: Simple enet server/client

Postby jdmcbride » Sep 11, 2016 4:41

if anyone has a copy of enet_example.rar, please share.

Return to “Libraries”

Who is online

Users browsing this forum: No registered users and 4 guests