Solved

Receive data from client

Posted on 2007-03-20
5
176 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

735 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