Solved

Help with Winsock Control

Posted on 2002-07-15
7
195 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

756 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