Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I allow multiple client connections to a host? (Newbie) 1

Status
Not open for further replies.

voydangel

Programmer
Dec 10, 2004
18
0
0
US
I have seen chat programs all over the place that allow 1 to 1 connections....I want more.
Long story short....
I am making an app and I want it to do this:
Up to 8 users (clients) connect to a host (server), when they connect, they are greeted with a login prompt. The login prompt checks for a valid user id/password. The password file is stored locally on the host/server machine.
This is not some kiddie chat program, but eventually will have real time "chat" capabilities (once I get a little better at this). =)

I already have a working login prompt (form) and it already connects to a DB via an ADODC. I can add users, remove users, and login. It checks passwords etc. What I need help in is the TCP/IP or winsock or SQL or whatever it is I need to use to allow remote users to login. As of right now, you can only login if your sitting locally at the host machine.

Running Win2k/VB6

Thanks in advance.
 
The easiest thing might be to keep track of the connected state of different clients by their IP address... unless you allow multiple instances of your client software to run from the same client machine... then you'll need the client to send some sort of ID along with each transaction request.
 
That doesnt sound like a bad idea...I dont plan on having multiple instances of the client software running so I wont worry about an ID for now. I like your idea, but I dont know how to do that. Can you supply some sample code, or at the very least some detailed pseudo code? I dont even know how to make a basic 1 to 1 connection. Should I use DirectPlay? (Not that I know how, just wondering) Or Is there a way to directly implement TCP/IP in VB code? Or should I be using SQL or something odd like that. The App doesnt really need Database support...the only time A DB is used is to do user/password checking. After that its mostly (At the moment) a kind of a desktop sharing program...that is...I am planning on making there be a "paint" window that the server can open and all the clients can see...as well as chat chat capabilities, and the ability for the server to view documents that the clients load (all of this is an MDI by the way.) Anyway....any code (or more suggestions) would help to get me on my way to being connected. Thanks
 
It sounds like you are re-creating Web Ex


Anyway... Have you tried using the Microsoft Winsock control? It is easier than using the Windows API to do your TCP/IP connections.

To use it in your VB project, go to the "Project" menu and select "Components" and then a dialog pops up and scroll down and put a checkbox next to Microsoft Winsock Control.

Then just draw the control on one of the forms in your server that will be loaded all the time. It is invisible when the program is actually running so you don't have to design your interface around it.
 
Sounds good, but I thought with winsock you could only have 1 client connected to the server at a time...?
 
Well yes but you can make a control array of winsock controls.

You want 9 winsocks ... because you have 8 clients.

Save one winsock for the server to take connection requests.

Take a look at this event:
Code:
Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)

You see how you get the requestID .... well you don't have to accept the request with the winsock that received it.

Instead you loop through your control array and find the first winsock that isnt busy and pass the requestID to THAT one instead and have it accept the request. That way the server always reserves one winsock for itself.

Dang, this is a lot to explain. I'm sure there are some good samples out on the net if you do a search on google.

Try keywords: vb6 Winsock control array server
 
If you have no luck finding a good sample let us know, I've got one around here somewhere on a backup CDROM.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top