|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sun Sep 28, 2008 8:00 pm Post subject: win32/winsock (part 2) |
|
|
|
|
- was trying to figure out how to have a simple multi client win32 winsock server
tried throwing a bunch of sockets into an array, that didnt work well
searching for examples yielded extremely low results, to the point where the post here was the 25th result on yahoo.
still trying to figure out some other win32 odds and ends, too, such as:
- still cant append last entry of list box
- figured out how to tooltip window client area, but cant figure out how to
- hook it to a control
- cant figure out how to display contents in a tab view
also dont forget that 'cant' and 'cant figure out' is a direct translation to 'im too lazy to look for it' and 'why reinvent the wheel?'
_________________ SSC Distension Owner
SSCU Trench Wars Developer
|
|
Back to top |
|
|
k0zy Server Help Squatter
Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Mon Sep 29, 2008 11:30 am Post subject: |
|
|
|
|
There are two ways of making a multi-client server.
Either you multiplex with "select" or create a new thread/process for each client.
IMO the mutliplexing is harder to code, but easier to maintain. While the thread/process way is easier to code, but harder to maintain because you have to deal with multithreading.
The threaded solution works like this:
- Create the server socket, bind it and start listening.
- Accept a new connection, start a thread and give the new thread the socket descriptor to work with.
- Start accepting new connections right away.
- Handle the connection in the thread.
The mutliplexing solution is a bit harder to explain.
What you do is, store the maximum socket descriptor and loop over all integers from zero to the max and use FD_* to handle the descriptor you are looping over.
This website looks like it's explaining it pretty good:
http://www.lowtek.com/sockets/select.html
I didn't read it, just searched and looked over it.
Attached are the source files for a server I created for an assignment at university, they were written under Linux but it shouldn't take much work to port them.
Before somebody starts complaining: I had to use fork(), we did a threaded solution, too, but I couldn't find it. _________________ It's a shark! Oh my god! Unbelievable!
Desktop.rar - 3.42 KB
File downloaded or viewed 43 time(s)
|
|
Back to top |
|
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Software by php BB © php BB Group Server Load: 1158 page(s) served in previous 5 minutes.
|