Solved

Help with Winsock Control

Posted on 2002-07-15
7
193 Views
Last Modified: 2013-11-13
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.
0
Comment
Question by:escheider
  • 4
  • 3
7 Comments
 
LVL 2

Expert Comment

by:yongyih
ID: 7154570
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.
0
 
LVL 4

Author Comment

by:escheider
ID: 7154577
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.
0
 
LVL 4

Author Comment

by:escheider
ID: 7154588
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.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 2

Accepted Solution

by:
yongyih earned 50 total points
ID: 7154633
If don't want to use array, how about using Microsoft Access to store those information?  A table with at least two fields.  one for nick name, another one for which winsock.(another field for status if you want ^_^)


when a connection fail/close, just delete that record for that instance of winsock.

when look for an user name/nick name, just search a record in table..

0
 
LVL 4

Author Comment

by:escheider
ID: 7154835
interesting thought.  Im actually using an Access database already to keep track of member names, so I'll give this a try.
0
 
LVL 2

Expert Comment

by:yongyih
ID: 7157311
have you solve your problem?? ^_^
0
 
LVL 4

Author Comment

by:escheider
ID: 7157328
yes it did...thanks for the quick and easy suggestion.  it works like a champ.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question