|
-
Apr 16th, 2006, 05:58 PM
#1
Thread Starter
New Member
multiple connections under one winsock control
myself and a friend of mine are both working on a very basic instant messaging program which uses an encryption function we've already written (wow! its already better than aol instant messenger!) and the one last thing we need to do is make the server... what i need now is a method that allows me to accept many many connections, without robbing the system resources, (like so many do by creating one control for each connection...)
-
Apr 16th, 2006, 06:16 PM
#2
Re: multiple connections under one winsock control
1. is this vb6 or .net or something else?
2. if its vb6 are you using winsock control, or winsock API or some other control?
-
Apr 16th, 2006, 06:52 PM
#3
Thread Starter
New Member
Re: multiple connections under one winsock control
1.) VB 6
2.) i was thinking winsock control, but if somthing else is more efficient than im open to it...
-
Apr 16th, 2006, 08:59 PM
#4
Re: multiple connections under one winsock control
oops I just noticed the *winsock control* in the thread title lol, anyway I would recommend using the winsock control, its pretty easy to use, theres many tutorials @ winsockvb.com I think there is a tut for multi connections
Q. are you new to the winsock control?
-
Apr 17th, 2006, 12:18 AM
#5
Thread Starter
New Member
Re: multiple connections under one winsock control
not really, i know the basics about transfering data from one client to another but nothing about multiple clients connecting to one server
-
Apr 17th, 2006, 04:47 AM
#6
Re: multiple connections under one winsock control
the way it works is the server winsock is a control array, winsock(0) is the interface when new clients connect, winsock(0) handles the connect attempt, and it should check if there is any winsocks which are closed (not in use) if there is one available, it will assign that winsock to accept the connection, winsock(0) will then wait for another connect attempt. If there s none available it should Load a new winsock array like
VB Code:
Load Winsock(Ubound(Winsock)+1)
'that will add one winsock to the control array
so you will have all of your clients cconnected to a winsock array, so then you can do things like broadcast messages like
VB Code:
for i = 1 to ubound(winsock)
if winsock(i).state = 7 then winsock(i).senddata "broadcasted MSG!!"
next i
the problem what a lot of people have is thay use Load() and Unload() each time a new connect attempt comes, and each time it closes, but if you do this, you wont be able to loop through to send msgs or check the states, because some of the winsock will be none existent, and it will cause an err if you try to check the state of something that doesnt exist, i.e
VB Code:
if winsock(i).state = 7 'will give error
if you need help with the coding let me know
-
Aug 10th, 2008, 09:21 AM
#7
New Member
Re: multiple connections under one winsock control
the182guy, Could you post here some example? just 3 projects, 2 projects are connected to the third project with control array
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|