Solved

Receive data from client

Posted on 2007-03-20
5
173 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
ID: 18759098

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
ID: 18759373
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
ID: 18759424

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
ID: 18759500
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
ID: 18759710
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

832 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