[SDL] SDL_net: What must be done on TCP_Recv/Send errors?

Jonathan Dearborn grimfang4 at hotmail.com
Sun Apr 20 04:52:38 PDT 2008


Hey, if anyone else is interested, I posted that library on my site as
"Jnet".  It's just a repackaging of Fast Events, NET2, and Beej's packing
functions, so you only need one dll.  I also included a
Packets_Example.h that leads you through defining packets.  Tell me how
it works for you!

http://pubpages.unh.edu/~jmb97/SDL.html

Jonny D


From: grimfang4 at hotmail.com
To: sdl at lists.libsdl.org
Date: Sat, 19 Apr 2008 09:12:02 -0400
Subject: Re: [SDL] SDL_net: What must be done on TCP_Recv/Send errors?







Hey,

I'm still dealing with an unrelated networking bug of my own, but I've put together some good stuff for starting networking code.  I was going to test it further and pimp it with more comments, but if you'd like what I have so far, I'll send it to you.  It builds from NET2 (which I definitely recommend), adding in some simple packet-forming functions (taken from Beej's tutorial) and simpler access functions to these.  It handles incomplete packets and multiple packets in the same buffer, as well (these could use more testing).  The stuff I have is a build of NET2 that includes Fast Events and those packet functions in a single dll.

Using this stuff, sending mouse coordinate data is as easy as sendZHLL(socket, P_MOUSECOORD, mx, my), and receiving it is like:
receiveH(type);
if(type == P_MOUSECOORD){
receiveL(mx);
receiveL(my);
}

I implemented a client-server thing for my game, where one player is the server.  The server handles everything while the clients just send info to the server.  I have host-recovery in that the clients send their IP addresses to the server, who relays the info back to each client.  If the server disconnects, the clients decide (based on ping) which client becomes the new host and then they connect to it.

Jonny D



> Date: Sat, 19 Apr 2008 11:19:21 +0100
> From: neil at cloudsprinter.com
> To: sdl at lists.libsdl.org
> Subject: Re: [SDL] SDL_net: What must be done on TCP_Recv/Send errors?
> 
> 
> 
> sorry vaugly bending the topic again but i will soon be thinking about 
> thinking
> about adding network capabilities to a project and i have never down anything
> network from my code so am worried i wont get it perfect enough so is 
> there any
> good examples of its use or how to best use it?
> 
> i will be wanting to send and recieve between 2 players their mouse coordiante
> as real time as possible, along with a small amount of other data.
> 
> I am not sure it it would make more sence to have an independent server rather
> than having 1 of the clients acting as server. so if a disconnect occurs the
> server can still hold the game which could be in a pause state until 
> the player
> finds thier connection.
> 
> any pointers for me most welcomed, thanks.
> 
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Going green? See the top 12 foods to eat organic.

_________________________________________________________________
Pack up or back up–use SkyDrive to transfer files or keep extra copies. Learn how.
http://www.windowslive.com/skydrive/overview.html?ocid=TXT_TAGLM_WL_Refresh_skydrive_packup_042008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20080420/5de26720/attachment-0001.htm 


More information about the SDL mailing list