Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
win32/winsock (part 2)

 
Post new topic   Reply to topic Printable version
 View previous topic  Quadtree C# fun! Post :: Post Invisionfree RSS Feed  View next topic  
Author Message
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1012
Offline

PostPosted: Sun Sep 28, 2008 8:00 pm    Post subject: win32/winsock (part 2) Reply to topic Reply with quote


  • 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
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Mon Sep 29, 2008 11:30 am    Post subject: Reply to topic Reply with quote

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 11 time(s)
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 116 page(s) served in previous 5 minutes.

phpBB Created this page in 0.125188 seconds : 29 queries executed (45.7%): GZIP compression disabled