Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem on Socket Program

Status
Not open for further replies.

surovi99

IS-IT--Management
Feb 11, 2005
28
US
Hi,

I am facing some problem on Socket programming.What the program does is the user gives a stock symbol on the client side and requests the server to send the corresponding stock price. Once the server sends the initial stock price,it makes variations in the stock price randomly at some interval say 5secs and sends them to the client. I have written the whole program but facing some problems. For example, i give below the codes that the server makes variations in the stock price and sends to the client. The problem is that if I give a small value for the timer control, all the varied (random)stock prices show up in the client side before the initial stock price and if I give a large number, only the initial stock price shows. Below are the codes for generating random stock prices:

private void timerprice_Tick(object sender, System.EventArgs e)
{
try
{
if (client_word_txt.Text != "")
{
if (counter < 3)
{
stprices_list = r.Next(100, 200).ToString("000");


byData = System.Text.Encoding.ASCII.GetBytes(stprices_list.ToString());


for (int i = 0; i < client_count; i++)
{
if (worker_socket != null)
{
if (worker_socket.Connected)
{

worker_socket.Send(byData);
}
}
}

counter = counter + 1;

} //if

else
{
timerprice.Enabled = false;
counter = 0;

}

} //if

}

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

Any quick reply will be very much appreciated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top