|
-
Oct 9th, 2000, 08:44 AM
#1
Thread Starter
Lively Member
If I was to make a server application (LAN), and I want to use winsock, how do I accept more than one connection?
Do I have to Load a new winsock component for each connection, like have one winsock to start with, then if one connects, another one is loaded etc.
But won't this create a conflict if they all listen to the same port?
Any solution is a good solution 
D
-
Oct 9th, 2000, 02:37 PM
#2
Frenzied Member
See Using the Winsock Control - paragraph "Accepting More than One Connection Request".
-
Oct 10th, 2000, 04:16 AM
#3
Thread Starter
Lively Member
Thanks, I've done that now. It works...
D
-
Oct 10th, 2000, 06:20 AM
#4
Thread Starter
Lively Member
Now, a new problem.
If someone disconnects, the wsock that that person used, is still there. That means that a new wsock is loaded for every new connection even though lots of wsocks are available.
I tried this code, but I wasn't allowed to change the index...
---------
Unload TcpServer(Index)
For i = Index + 1 To intMax
TcpServer(i).Index = TcpServer(i).Index - 1
Next
intMax = intMax - 1
---------
D
-
Oct 10th, 2000, 04:46 PM
#5
Frenzied Member
Try looping through the control array looking for the first socket that has been closed and do another Accept.
I haven't tried this but I think it should work. Let me know if it requires any other steps. I don't think it will because I have seen my socket state go from sckConnected to sckClosing to sckClosed when the other side shut down. So with a state of sckClosed, you should be able to do the Accept.
-
Oct 12th, 2000, 12:32 PM
#6
Fanatic Member
sock(0) is listening
NumSocks is the total number of socks
----------------
connection request
for a = 1 to NumSocks
if sock(a).state = 0 then 50
next a
NumSock=NumSocks+1
load sock(NumSocks)
a=NumSocks
50
Sock(a).accept requestid
etc etc
Kurt Simons
[I know I'm a hack but my clients don't!]
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
|