Advertisement

Creating a Winsock class...

Started by September 29, 2002 06:43 AM
4 comments, last by elis-cool 22 years, 4 months ago
Ok, so im reading this winsock2 tutorial here on gamedev (where u make a rock, paper, siscors game), and I can understand all the indivdual code snippits, but im trying to put it all together into a nice generic claass, but im finding it really hard, im just not getting how to do it with all the client and server differences and when & where to do what... a little help plz
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Do you have any specific problems or is it just a general difficulty with the overall design?

------
Andrew
Advertisement
General problems with the overall design.. and sortof like when you create a socket, your only ment to bind server sockets.. im not getting it...
[email=esheppard@gmail.com]esheppard@gmail.com[/email]
Well, I assume that you would have seperate classes for client and server sockets.


          BaseNetwork             |      --------------      |             |   ServerLayer   ClientLayer  


So your base network has stuff that both client and server sockets need like the initial base socket creation and things like send(), recv(). Then you can make your serverlayer handle things like bind(),accept(), listen(). While your clientlayer will handle things like connect()

-------
Andrew


http://code.jakobbieling.de/

contains such a thing. the operations you use are multithreaded too.

what I personally would like is a UDP wrapper class. since i dont know winsock, i dont know how to use UDP.
I wrote a Winsock Class recently. I had a client class and a server class. Each works independantly from each other. I basically had a few functions in each class, which controlled the connections, the receiving of data and the transmission of software. When the client or server was set up, it set up a second thread which used a select() blocking call. This set up a message queue and data received was added to the end of this queue and when data was wanted by the application, the class removed it from the queue. It worked similarly in both the client and server classes.

Hope this helps.

This topic is closed to new replies.

Advertisement