Click here to Skip to main content
16,003,315 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#


I need the steps involved in DEVELOPING and application that will allow client connect to a server and then the client will be able to communicate with each other
Posted
Comments
Krunal Rohit 20-Mar-14 12:27pm    
Socket, RMI, Service ??

-KR
ZurdoDev 20-Mar-14 12:44pm    
Step 1. Write code.
Step 2. Debug.
Step 3. Goto Step 1.
Krunal Rohit 20-Mar-14 15:31pm    
5.
-KR

In Win Forms, the client is connected to the server (and vice-versa) using the WinSock API. It is a relatively straight forward process. MSDN's documentation, Running the Winsock Client and Server Code Sample, should help.
 
Share this answer
 
simply use signalr here's an example Asp.Net SignalR Chat Room[^]
its web example you can use any kind of client too like java, winform or wpf etc
Best of Luck
 
Share this answer
 
These are the main ways that you can implement Client - Server architecture.

  • Socket
  • RMI
  • Web Services


Sockets in C#[^]
A Complete TCP Server/Client Communication and RMI Framework in C# .NET - Implementation[^]
Creating a C# Service Step-by-Step: Lesson I[^]

-KR
 
Share this answer
 
Client :
Java
package client_server;


import java.net.*;
import java.io.*;
public class Client
{
	static void show(String s)
	{
	   System.out.println(s);
	}
        
   
	public static void main(String a[])
	{
	   int port=1500;
	   String server = "localhost";
            Socket s1=null;
	   BufferedReader input;
           PrintWriter p1;
	   String msg = null;
		try
		{
			s1=new Socket(server,port);
			show("connected with server");
                        p1= new PrintWriter(s1.getOutputStream(),true);
                        p1.println(5);
                        p1.println(10);
			input= new BufferedReader(new InputStreamReader(s1.getInputStream()));
			msg=input.readLine();
			show("from server");
			show(msg);
			s1.close();  
		}
		catch(Exception e)
		{
			 System.out.println("Exception :"+e);
		}
           
         
	}
}






Server :


Java
import java.net.*;
import java.io.*;
import java.util.*;


public class Server
{
	static void show(String s)
	{
	   System.out.println(s);
	}
	public static void main(String a[])
	{
	   int port=1500;
	  ServerSocket s2;
       	  Socket s=null;
	   PrintWriter p1;
	   String msg = null;
           int b,c,d;
           BufferedReader input;
		try
		{
			s2=new ServerSocket(port);
			show("server is waiting");
			s=s2.accept();
			p1= new PrintWriter(s.getOutputStream(),true);
			show("new connection accepted");
			
			input= new BufferedReader(new InputStreamReader(s.getInputStream()));
			c=Integer.parseInt(input.readLine());
                        		d=Integer.parseInt(input.readLine());
                       		 b=c+d;
                      		  p1.println(b + " ");
        		s.close();   
			}
		catch(Exception e)
		{
			 System.out.println("Exception :"+e);
		}
           
	}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900