Solved

Receive data from client

Posted on 2007-03-20
5
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 45

Expert Comment

by:Kent Olsen
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:
Kent Olsen 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

688 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