Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


My network API

This topic is 5957 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

After a few days of coding Im starting to see the end of it in the horizon. What I did is build a small c++ library. it looks like this: CInetBase - Opens Winsock and handles OS specific stuff CInetConnection - Base class for connections. | +CTCPConnection - Derived from CInetConnection | +CUDPConnection - Derived from CInetConnection | +CIPXConnection - Planned only CInetPacket - Virtual class for packets | +-CPktHello - Aknowledges connection +-CPktBye - Discconnects +-CPktText - Sends a packet containing text +-CPktData - Sends a packet containing data +-CPktRelay - Moves a connection (from TCP to UDP or to a different server, port) How it works is, you start up the baseclass to init everything. Then you open a connection, either with Connect (connects to remote host) or with Listen (listen for incoming traffic). Sending/recieving is quite easy, you just derive a class from CInetPacket and tell it how it should handle data. And off you go. Example:
int main ( int argc, char **argv ) {
 CInetBase _inetBase; 
 CTCPConnection _myConn("",9090); 
 _myConn.SendPkt(new CPktText("This is a test string");

 return 0;
The CPktText class does this:
class CPktText : public CInetPacket

   CPktText (char *a_szText) {
      this->m_nLength = strlen(Text);
      this->m_ptType = CInetPacket::Pkg_Text;

The connection classes also do either call callbacks when remote connections connect/disconnect or handle them by themselves. Right now im working on the CUDPClass, Im about to implement a sequencing system. Im still working on it so there is no point in talking about it, since Im not sure how it all will work yet :D Im considering to release the sourcecode and perhaps write a tutorial or something. Would this be of any intrest or is it to basic for you Guru people you?

Share this post

Link to post
Share on other sites
of course! a network api is always interesting. i hope you can write a tutorial about it. if possible please email me the source code (yoshi_x@hotmail.com). keep up the good work!

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!