|
-
Nov 13th, 2000, 12:51 PM
#1
Thread Starter
Lively Member
Hey All,
I'm a semi-TCP/IP newbie and I've been trying to write a TCP/IP based chat server in VB using the WinSock control.
I started my project based on the short tutorial on WinSock here on VB-World. I guess
all it really is a TCP/IP connection manager. Listen for connection requests, allocate
another winsock control, set it to 'listen', ad infinitum.
The chat clients passes as part of the data stream which user it wants to send data to.
So i just parse that off, perform a look up of which winsock relates to that user and
then send the data.
The problem is after I allocate a couple connections, only the latest connection allocated
will recieve messages. None of the previous connections will recieve data.
Can the TCP/IP in VB only listen to 1 connection at a time? Any ideas why only the latest
connection will recieve data?
Sorry I dont have any code to post at the moment, I'm at work 
Is what I'm trying to do even possible in VB?
Thanks for any ideas...
-
Nov 13th, 2000, 02:19 PM
#2
Hyperactive Member
Your best bet is to put each "Client" into an array containing the winsock index they are on . Then when a msg comes in that's is ment for all clients to recieve you simply parse your array for the sock index . I hope your good with arrays because you'll have to catch the index in the winsock_Disconnect event to remove them from your array otherwise you'll error out trying to send data on a sock thats no longer connected .
Best of Luck ,
[]P
Visual Basic 6 SP4 on win98se
QUIT THE RAT RACE BECAUSE YOUR MESSING THE WORLD UP !!!!!
-
Nov 13th, 2000, 10:15 PM
#3
Lively Member
Sounds like each time you are trying to put the new socket in a listen state.
1 socket should be assigned as a listening socket.
another socket (array) handles assigned connections.
Code:
Private Sub Form_Load()
'Start a socket listening for connection requests
sckListen.LocalPort = 100
sckListen.Listen
End Sub
Private Sub sckListen_ConnectionRequest(ByVal requestID As Long)
Dim iIndex As Integer
'Get a the next free socket index
iIndex = UBound(sckConnections) + 1
'Load a new socket to handle the new incoming connection
Load sckConnections(iIndex)
'Pass the 'socket handle' the new socket so it can handle the incoming data
sckConnections(iIndex).Accept requestID
End Sub
Hope this helps
-
Nov 14th, 2000, 10:54 AM
#4
Frenzied Member
-
Nov 14th, 2000, 03:29 PM
#5
Thread Starter
Lively Member
ive got my app working great now thanks to you guys =)
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
|