Solved

Receive data from client

Posted on 2007-03-20
5
169 Views
Last Modified: 2013-11-26
Hello experts,

I am a server waiting for the client and receivng the data from the client periodically.When I receive the data ,I have to make some calculations on the data received and I have to paint the form accordingly.I am working in VC++ .NET.
I will be receiving the data from the client for every 10 seconds of time.I want my program to wait at the receive function till it recives the data and then paint periodically.

I made the socket non blocking but I am not able to achieve what I wanted.

Here is the sample of code......

do
{
iResult = recv(s,buffer,256,0);//I want the function to wait here till it receives the data from client for every iteration.
//do some paint opertion here.....
}wjile(iResult!=-1);

0
Comment
Question by:tatikor_143
  • 3
  • 2
5 Comments
 
LVL 45

Expert Comment

by:Kdo
Comment Utility

Perhaps I don't understand.  If the client is sending data every 10 seconds, just define the server socket as blocking.


Kent
0
 

Author Comment

by:tatikor_143
Comment Utility
If I make the socket as blocking then I will not be able to perform the paint operations but I am sure that I will be receiving the data.
0
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
Comment Utility

You shouldn't be blocking from the main thread.

Create another thread and let it handle the connection(s).  When the thread receives data, it should single thread through the main thread to perform the screen updates and paints.

0
 

Author Comment

by:tatikor_143
Comment Utility
Hi kent,

I inserted the code in a button handler......
When I click the button,it starts receiving the data from the client and paints on the form......
If I create  a thread for receiving the data then How can I suynchronise the paint operation ?
any idea.....
0
 

Author Comment

by:tatikor_143
Comment Utility
I am still in a confusion wether I have to look towards the socket side or towartds the .NET side....

I dont know Wether I am going in a right way.....
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now