[gameprogrammer] Re: Networking for games
- From: Vince <uberneen@xxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Mon, 9 May 2005 14:25:10 -0700 (PDT)
I can do that but then I'll need to add stdin to my
fd_set and poll it for keystrokes. The normal SDL
input events need a window.
--- Jake Briggs <jacob_briggs@xxxxxxxxxxxxxxx> wrote:
> You only need to initialise video, you dont need to
> make the window
> appear :)
>
> Vince wrote:
>
> >That was actually my first choice. The problem is
> >that SDL doesn't receive events unless you have a
> >window and I want the server to run without X. If
> you
> >know of a way around that, please tell me, I'd love
> to
> >go back to FE and net2.
> >
> >Vince~
> >
> >--- Jake Briggs <jacob_briggs@xxxxxxxxxxxxxxx>
> wrote:
> >
> >
> >>Isnt Bob Pendletons SDL_net2 library threaded? If
> >>you used that, you
> >>would get network threading for free.
> >>
> >>Vince wrote:
> >>
> >>
> >>
> >>>I've been reading through the Quake II source and
> >>>
> >>>
> >>it
> >>
> >>
> >>>heavily agrees with your advice here. Now I'm in
> >>>
> >>>
> >>the
> >>
> >>
> >>>middle of a discussion with a friend about
> >>>
> >>>
> >>threading.
> >>
> >>
> >>>I was contemplating having a thread dedicated to
> >>>networking, but it looks like that will make my
> >>>project more complex than I want it to be. I'm
> >>>
> >>>
> >>also
> >>
> >>
> >>>hearing that debugging threads is a real pain.
> >>>
> >>>
> >>Right
> >>
> >>
> >>>now we fork on new connections since we're not
> >>>
> >>>
> >>going
> >>
> >>
> >>>for multiplayer right now.
> >>>What are your (or anyone's) experiences with
> >>>threading?
> >>>
> >>>Vince~
> >>>
> >>>--- Olof Bjarnason <olof.bjarnason@xxxxxxxxx>
> >>>
> >>>
> >>wrote:
> >>
> >>
> >>>
> >>>
> >>>
> >>>
> >>>>I don't know of any industry standard way for
> this
> >>>>
> >>>>
> >>-
> >>
> >>
> >>>>after all it is
> >>>>your own protocol.
> >>>>
> >>>>One way of doing this, which is easily re-used
> >>>>
> >>>>
> >>later
> >>
> >>
> >>>>on, is NOT
> >>>>putting any "type" specifier in the header, ONLY
> >>>>
> >>>>
> >>the
> >>
> >>
> >>>>size and the
> >>>>data. The type could then be put in the data
> >>>>
> >>>>
> >>instead
> >>
> >>
> >>>>- making re-use
> >>>>of this protocol easy in the future.
> >>>>
> >>>>Decide on a max-length first of all. Say you
> >>>>
> >>>>
> >>decide
> >>
> >>
> >>>>200 bytes to be
> >>>>max length. Then a one-byte-header is enough,
> and
> >>>>you could go with a
> >>>>c structure like
> >>>>
> >>>>struct Message {
> >>>> unsigned char length;
> >>>> unsigned char data[200];
> >>>>};
> >>>>
> >>>>.. and the corresponding read/write procedure
> >>>>prototypes:
> >>>>
> >>>>int writeToSocket(SockStructure* sock, Message*
> >>>>msg);
> >>>>int readFromSocket(SockStructure* sock, Message*
> >>>>msg);
> >>>>
> >>>>Decide whether you want these to be blocking or
> >>>>non-blocking. If you
> >>>>are already using threads, then blocking is
> quite
> >>>>feasible. If your in
> >>>>a single-thread situation, non-blocking (ie.
> >>>>polling) is easier on the
> >>>>responsiveness of the application.
> >>>>
> >>>>Be careful in the implementation, especially in
> >>>>
> >>>>
> >>the
> >>
> >>
> >>>>readFromSocket()
> >>>>procedure, since the whole message might not
> >>>>
> >>>>
> >>arrive
> >>
> >>
> >>>>and also two
> >>>>messages in a row might be concatenated. [ use
> >>>>
> >>>>
> >>some
> >>
> >>
> >>>>helper
> >>>>array/structure in order to store parts of
> arrived
> >>>>messages ..
> >>>>memcpy() might be handy here ].
> >>>>
> >>>>Good luck!
> >>>>
> >>>>/Olof
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>__________________________________
> >>>Yahoo! Mail Mobile
> >>>Take Yahoo! Mail with you! Check email on your
> >>>
> >>>
> >>mobile phone.
> >>
> >>
> >>>http://mobile.yahoo.com/learn/mail
> >>>
> >>>
> >>>---------------------
> >>>To unsubscribe go to
> >>>
> >>>
> >>http://gameprogrammer.com/mailinglist.html
> >>
> >>
>
=== message truncated ===
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] Re: Networking for games
- From: Jake Briggs
Other related posts:
- » [gameprogrammer] Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- » [gameprogrammer] Re: Networking for games
- [gameprogrammer] Re: Networking for games
- From: Jake Briggs