473,504 Members | 13,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Client/Server model

1 New Member
Hi all,

I am trying to write a client/server application for TCP or UDP actually at this point the protocol is not important, I am trying to sort out the logic / flow diagram of the problem.

I will initially configure 50 different physical machines and on each machine there will be three servers running. There will then be one client machine that will communicate with each of these servers. Each server will perform a different a different task and hence has to be kept separated from the others.

The problem I am having is about the logic of this system.

The client machine will have to create a connection to each server, (50 *3) so 150 client connections have to be made. Originally I wanted to have two threads per client, one to send data and one to receive data. The reason being that data can be sent without receiving data and vice versa so something like

Expand|Select|Wrap|Line Numbers
  1. NetworkStream myData = socket.GetStream();
  2. while(true)
  3. {
  4.     //block and wait for read
  5.     myData.read();  
  6.  
  7.     ProcessData();
  8.  
  9.    myData.Send(Response);
  10. }
  11.  
in one thread won't work.

I was thinking of implementing something more like

Expand|Select|Wrap|Line Numbers
  1.  
  2. ReceiveThread()
  3. {
  4.   While(true){
  5.     //block and wait for data to arrive
  6.     myData.Receive()
  7.  
  8.     //Use delegates and events to notify data has been received and parsed
  9.     Notify_application_logic_data_received(data)
  10.    }
  11. }
  12.  
  13. SendThread()
  14. {
  15.  
  16. Array SendBuffer = Empty;
  17.  
  18.    While(true)
  19.    {
  20.       //Block and wait for data to be placed in send buffer
  21.       WaitForNotification();
  22.  
  23.       myData.send(SendBuffer);
  24.    }
  25. }
  26.  
  27. Main()
  28. {
  29.    receivedata += notify(ReadData);
  30.  
  31.    mainSend();
  32. }
  33.  
  34. ReadData()
  35. {
  36.     /whatever has to be done
  37. }
  38.  
  39. mainSend()
  40. {
  41.    //append data to SendBuffer
  42.    //wake up  SendThread to send the data
  43. }
  44.  
The problem is that I will have 300 threads just for communications alone let alone the rest of the application logic. I am afraid that I will spend more time switching threads that actually doing other work.

I then looked at asynchronous communications and it looks like I will have to constantly poll each connection, to see if data available to read and if the application logic has provided some data to send.

Has anybody encountered such a problem before. Is 300 threads to much to have ? If each thread is actually blocked until it is woken up either by an event saying data available to read or by me saying here is some data to send so wake up. As you have probably noticed this is C# code on a windows machine.

Any suggestions will be greatly appreciated.
Apr 7 '08 #1
1 1223
ShahbazAshraf
36 New Member
I think if their is larger number of threads then its good to use different process (i.e. cloning of process) better than creating a huge amount of threads. Their is an ancient war b/w Processes Vs Threads. So in your problem if u think thread switching may be time consuming and windows doesnot handle 300 threads in while, then distribute the application in multiple process.
Apr 7 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4316
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
0
776
by: Erik Cruz | last post by:
Hi. I have a vb.net application that will be installed on a server. The client machines will have shortcuts to this application. I have some questions about this model: 1) When the clients...
7
3280
by: rdh | last post by:
Hi all, I am in process of developing a Server in C++ supporting multiple protocols. The server will be exposing various functionalities, and the clients can communicate over any of the...
18
7342
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
3
469
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program...
6
5510
by: Julius Fenata | last post by:
Dear all, I have created client-side scripting to trigger event onChange from code-behind, like this: DropDownList1.Attributes = "GenerateArticleID()"; At the script on Windows Form, I...
3
1585
by: Larry David | last post by:
Hi, I'm just trying to wrap my mind around the ASP.NET model. Let me walk you through a trivial scenario: Let's say I have a form containing a text box where the user enters his name. It also...
0
1102
by: Thomas Jespersen | last post by:
Hello Say I have a Web Service which I want to send a object from my Domain Model to a WinForm client. PS: Yes I have a reference to the Domain Model Assembly on both the Client and Server...
3
3725
by: evelyne0510 | last post by:
Hi all, I have created a XML-RPC model (with server and client) written in Java. I want to call the methods in another XML-RPC model written in Python. I know that in Java, I can use like...
7
3159
by: Samuel | last post by:
Hi, I am looking for some recommendations for client/server technologies and for the communication involved. I am currently planning to port a Perl application that has grown out of...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.