HashTable problem-Pls guide

G

Guest

Hello Everybody:
I have created a multiclient server application. I am storing the client information and the thread hashcode in a hashtable. I want to send the information back to the client from the server by selecting the thread hashcode from the hashtable and sending the information to the same client.. THe code I have developed is as follows:

try
{

int key = System.Int32.Parse(txtThreadCode.Text);
if(threadhashtable.ContainsKey(key))

{

Object objData = txtDataRx.Text;
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());

m_socWorker.Send (byData);
}
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}

However the code is not working and the debugger does not go into the if loop. and does not catch any exception..
Pls guide whats happening.. Thanks,

Kapi
 
N

Nicholas Paldino [.NET/C# MVP]

Kapil,

You might want to try catching just Exception, so any exception can be
caught. If an exception is thrown, it will be caught then.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

KapilShah said:
Hello Everybody:
I have created a multiclient server application. I am storing the client
information and the thread hashcode in a hashtable. I want to send the
information back to the client from the server by selecting the thread
hashcode from the hashtable and sending the information to the same client..
THe code I have developed is as follows:
try
{


int key = System.Int32.Parse(txtThreadCode.Text);
if(threadhashtable.ContainsKey(key))

{

Object objData = txtDataRx.Text;
byte[] byData = System.Text.Encoding.ASCII.GetBytes(objData.ToString ());


m_socWorker.Send (byData);
}
}
catch(SocketException se)
{
MessageBox.Show (se.Message );
}

However the code is not working and the debugger does not go into the if
loop. and does not catch any exception..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top