Link to home
Start Free TrialLog in
Avatar of escheider
escheider

asked on

Help with Winsock Control

Hello Experts:

What I actually need is some help with Winsock connection management.  I am working on an application that has some functionality similiar to ICQ or AIM.

I have a client application and server application and can successfully connect multiple clients to the application, but the problem i am having is managing who is connected to each instance of the Winsock control.

Does anyone have any suggestions on how to manage this, so when user A on Winsock(1) wants to send a message to user C on Winsock(3), this can be accomplished successfully.
Avatar of yongyih
yongyih
Flag of Malaysia image

How about create a two dimension array.
nick name and which winsock
user A , 1
user B , 2
user C , 3

when user send message, winsock will send "*user C*" in front of message.  e.g.  "*user C*Hi, how are you?"
then you will have a function to retrieve the 'user C' from message.

after that, use it to check the nick name in array and send to correct person.
Avatar of escheider
escheider

ASKER

I was thinking along those lines but won't that be tremendous overhead if say 100 people connect to the server?  

Also, what if user B drops out --  that would require some complex array management.
I think it would be slick to have it store the connection that the users are connected to, then that could be passed as a parameter..so

User(1)=UserA
User(2)=UserB

and the array element would indicate which Sock(x) that user is connected to...but seems like complex array management.
ASKER CERTIFIED SOLUTION
Avatar of yongyih
yongyih
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
interesting thought.  Im actually using an Access database already to keep track of member names, so I'll give this a try.
have you solve your problem?? ^_^
yes it did...thanks for the quick and easy suggestion.  it works like a champ.