473,387 Members | 1,362 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Multithreaded TCP Socket server.

3
I'm working on a server program that will allow multiple clients to connect then send and receive the catch is that i don't want all the date from 1 client sent to every other client. I only want Client 1 to receive data from Client 2 or Client 3 if they send numbers that are in a certain range. my main problem right now is getting the server to accept multiple clients and send them any data back at all. i don't know if it's important but the clients do not disconnect after data is sent the server will have to keep the thread open and wait for more data, only closing the thread if the Client clicks a disconnect button.

here is what i have so far (i left some parts out as they don't have anything to do with Clients connecting)
Expand|Select|Wrap|Line Numbers
  1. static void Main()
  2.         {
  3.  
  4.         static TcpListener ServerSocket = new TcpListener(16487);
  5.         static TcpClient clientSocket = default(TcpClient);
  6.  
  7.  while (true)
  8.             {
  9.                 if (blnAllowConnect == true)
  10.                 {
  11.                 ClientCounter += 1;
  12.                 clientSocket = ServerSocket.AcceptTcpClient();
  13.                 Console.WriteLine("Client :" + Convert.ToString(ClientCounter) + " has started!");
  14.                 handleClinet client = new handleClinet();
  15.                 client.startClient(clientSocket);
  16.                 }
  17.             }
  18.         }
  19.  
  20. public class handleClinet
  21.     {
  22.  
  23.         TcpClient clientSocket;
  24.         string clNo;
  25.         public void startClient(TcpClient inClientSocket)
  26.         {
  27.             this.clientSocket = inClientSocket;
  28.             Thread WorkThread = new Thread(TransferData);
  29.             WorkThread.Start();
  30.         }
  31.         private void TransferData()
  32.         {
  33.             //Here is where I'm getting stuck,
  34.             //I've tried a few different things
  35.             //but none have quite worked out
  36.         }     
  37.     }
  38.  
as for the client side its basically just sends a String
with something like 55 in it and waits for data back.
the idea is that the data it gets back is only from Clients 10 numbers above or below 55.

thank you for all the help I've been stuck trying different methods over the past couple days.
Nov 30 '11 #1
0 2107

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

Similar topics

1
by: Google Mike | last post by:
I want to prepare some training for some new employees regarding the topic of multithreaded socket services implemented in PHP. I've been able to implement this with my own design, but I'd like to...
7
by: Sidd | last post by:
Hi, I tried finding and example of multithreaded client-serve program in python. Can any one please tell me how to write a multithreaded client-server programn in python such that 1.It can handle...
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
7
by: Colin | last post by:
I'm writing a little console socket server but I'm having some difficulty. Can I ask your advice - where is the best place to get some help on that topic? It would be nice if some people who knew...
9
by: Macca | last post by:
Hi, I have a synchronous socket server which my app uses to read data from clients. To test this I have a simulated client that sends 100 byte packets. I have set up the socket server so...
0
by: Macca | last post by:
Hi, I am writing an asychronous socket server to handle 20+ simulataneous connections. I have used the example in MSDN as a base. The code is shown at end of question. Each connection has a...
9
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame....
4
by: Engineerik | last post by:
I am trying to create a socket server which will listen for connections from multiple clients and call subroutines in a Fortran DLL and pass the results back to the client. The asynchronous socket...
0
by: doc | last post by:
Hi Hard to know where to post this and I don't want to double post it - please move it if you need to, I am trying to connect a Flash client socket (XML) to a php socket server (using Flash 8 and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.