|
-
Mar 31st, 2004, 02:21 PM
#1
Thread Starter
Lively Member
Client Server Application-Modified
Hello Everybody:
I have built a client server example using socket class where the server sends data to all the clients simultaneously. Now I want to send the data to that or one client when selected.. I have written the code to send the data to all clients. How do I modify the code so that I can select only each individual key to send the data to one client when selected...
private void SendDataToAllClient(string str)
{
foreach (int sKey in socketHolder.Keys)
{
Socket s = (Socket)socketHolder[sKey];
if(s.Connected)
{
Byte[] byteData = ASCII.GetBytes(str.ToCharArray());
try
{
s.Send(byteData, byteData.Length, 0);
}
catch
{
// remove the bad client
CloseTheThread(sKey);
}
}
}
Thanks,
Kapil
-
Apr 1st, 2004, 10:22 AM
#2
Frenzied Member
You would need to know the Socket key you want to send to, then in the foreach loop just check if the key value matches the one you want to send it to.
Being educated does not make you intelligent.
Need a weekend getaway??? Come Visit
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
|