Hello guys,
I am new to the programming world, and began by programming a chat app in VB6, which I think its obsolete as far as server side , but
I am now starting to go to C# directly, and I am facing problems, being a new programmer who is learning on his own.
The Thing is that, in VB6 i used to use MSWINSCK.OCX, which is like an object you drop in the design area, and it porvides event driven event handlers, like onconnect, onclose, onSCKERROR, onsendcomplete, and so on. now i am having difficulty doing the same
thing in VS2005, because now i have to write the code, for the event driven things, Like OnDisonnection,
And i have no way of knowing if a client has disconnected or not so what do i do in this case?
I filed a suggestion with product feed back, and they said this is not going to happen in VS2005, but will be considered for the next release, called Orcas, But in the mean time , what do i have to do to start learning this?
I want to program a MultiThreaded Asynchonous Socket Server, that is able to connection many users (100 000 ++), and be responsive at the same time, so there is no lag (i use multithreading here).
So What do i do? can you help me to start..
The main point here, is for me to learn, i beleive this kind of project, which will involve SQL Db, and C# programming will help me alot and it will expand my understanding. I have the motivation, and the drive, but i want some help to start..
Any suggestion would be helpfull, thanks alot
-
-
If you are completely new to the programming I would suggest starting with something simpler. A chat app is good enough example to get you going as far as network programming is concerned but I'm not sure it's simple enough for a programming newbie.
But if you really want to do that Socket class from a System.Net.Sockets namespace is excellent replacement for the mswinsck.ocx. It supports event driven, synchronous or asynchronous model. You definitely do know when a client disconnects. There is an abundance of documentation on MSDN and many many samples on the Internet. Check out http://www.codeproject.com, it's chock full of smaller code snippets that are easy to digest, especially if you like to learn from example.
Finally, connecting to 100,000+ users is not going to be possible, regardless of the asynchronicity of your server. Windows XP will choke after about 500 connections - it will work but the network access will be really slow. That's why most P2P apps out there actually limit number of the connection to something more reasonable. My BitTorrent implementation for example uses only about 60 connections for each torrent. And I do use asynchronous multithreaded sockets, there's nothing magic about this kind of approach. -
Than you for your reply,
What about the Windows Server 2003? Would it choke at 500 concurrent connection?
And, can you show me a small example (code) as to how to know if a remote client has disconnected or is idle? -
Shark_M wrote:Than you for your reply,
What about the Windows Server 2003? Would it choke at 500 concurrent connection?
And, can you show me a small example (code) as to how to know if a remote client has disconnected or is idle?
I don't know about Windows Server, but in most scenarios you don't want 500 connections. Imagine how much memory you'd need to keep some of the state for each of the connections.
In most cases, what you'd do is have some number of connections active and keep the list of all possible clients you'd possibly want to connect to and then connect and disconnect as need arises.
You can trivially know if a client is idle by making sure that if some number of seconds passes without any activity, then that client is idle
To detect if a client has disconnected I'd need to know which model (synchronous or asynchronous) you are using. I will assume that it's the latter. In that case, it is enough to detect if Socket.EndSend returned 0 (zero) bytes. Also, clients can disconnect in many other scenarios and sometimes .NET will throw SocketException or ObjectDisposedException, so most if not all of your Socket calls need to be wrapped in try/catch blocks.
Again, I recommend you start with something simple and move on to more complex stuff gradually. You won't be able to write a robust network applications by asking questions on forums like this one. You need to get a book on network programming and check out some .NET code examples. The site I mentioned in a previous post is excellent resource. -
I am leaning gradually, and thanks for the site.
But one question is this, How does Msn Messenger, or hotmail, serves Millions of clients at a given point in time? wouldnt their server's memory get utilized to the point that perfomance is affected, or what do they do to allow 1000000s of msn messenger clients to talk and interact with each other at any given momen in time, same is the case for yahoo messenger. -
Shark_M wrote:I am leaning gradually, and thanks for the site.
But one question is this, How does Msn Messenger, or hotmail, serves Millions of clients at a given point in time? wouldnt their server's memory get utilized to the point that perfomance is affected, or what do they do to allow 1000000s of msn messenger clients to talk and interact with each other at any given momen in time, same is the case for yahoo messenger.
They do this by having servers with multiple CPUs, many gigabytes of RAM, and by clustering together dozens if not hundreds of servers.
And MSN Messenger tries to do all peer-to-peer communication through a direct connection if possible. Connections through the central servers are only used if needed. -
Shark_M wrote:Iwouldnt their server's memory get utilized to the point that perfomance is affected, or what do they do to allow 1000000s of msn messenger clients to talk and interact with each other at any given momen in time, same is the case for yahoo messenger.
Nope
They've got dozens of server farms located all over the world, each with a few good thousand boxen in.
Each connection is routed to a server with enough free capacity.
I have my doubts that the Messenger Switchboard servers run Windows, more likely a variant of UNIX, most likely BSD.
Hotmail, even, was running on Linux at least up 'til 1999. To my knowledge, they're still using a CGI application from yesteryear, its only now they're transitioning to compiled ASP.NET
-
W3bbo wrote:I have my doubts that the Messenger Switchboard servers run Windows, more likely a variant of UNIX, most likely BSD.
Wow, is that you, Beer?
Is there any basis for that statement? Didn't think so.
Besides, Bill Gates said at the Windows x64 launch that they were able to drastically reduce the number of servers used by Messenger by moving over to Windows Server 2003 x64 (from regular Windows Server 2003).
EDIT: Just traced MSN Messenger signing in with Fiddler. The servers are (or at least claim to be) running IIS 6.0. -
Sven Groot wrote:

W3bbo wrote:I have my doubts that the Messenger Switchboard servers run Windows, more likely a variant of UNIX, most likely BSD.
Wow, is that you, Beer?
Is there any basis for that statement? Didn't think so.
Besides, Bill Gates said at the Windows x64 launch that they were able to drastically reduce the number of servers used by Messenger by moving over to Windows Server 2003 x64 (from regular Windows Server 2003).
EDIT: Just traced MSN Messenger signing in with Fiddler. The servers are (or at least claim to be) running IIS 6.0.
Well, I just had my doubts, alright?
Microsoft targets their Windows Server software at Small to Large businesses, I don't see them pushing WS2003 at "massive" operations, such as super-computing.
-
W3bbo wrote:
Microsoft targets their Windows Server software at Small to Large businesses, I don't see them pushing WS2003 at "massive" operations, such as super-computing.
Look harder
Server 2003 Datacenter Edition
Server 2003 Compute Cluster Edition -
W3bbo wrote:
Microsoft targets their Windows Server software at Small to Large businesses, I don't see them pushing WS2003 at "massive" operations, such as super-computing.
You'd better watch out, MS is becoming a very important player on that market. Soon, there will be a Cluster Edition of Windows 2003 server, it's looking very good! -
A Windows-based supercluster is scalable up to 256 nodes, with up to 4 processors per node.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.