Click here to Skip to main content
15,895,557 members
Home / Discussions / C#
   

C#

 
Generalunique identifier on a thread Pin
sameerhanda10-Feb-05 8:30
sameerhanda10-Feb-05 8:30 
GeneralRe: unique identifier on a thread Pin
C# Genius10-Feb-05 8:44
C# Genius10-Feb-05 8:44 
GeneralRe: unique identifier on a thread Pin
Dave Kreskowiak10-Feb-05 9:02
mveDave Kreskowiak10-Feb-05 9:02 
GeneralRe: unique identifier on a thread Pin
Stefan Troschuetz11-Feb-05 0:18
Stefan Troschuetz11-Feb-05 0:18 
GeneralClient/Server Pin
Soumya Mulukutla10-Feb-05 6:58
Soumya Mulukutla10-Feb-05 6:58 
GeneralRe: Client/Server Pin
Michael P Butler10-Feb-05 8:15
Michael P Butler10-Feb-05 8:15 
GeneralRe: Client/Server Pin
S. Senthil Kumar10-Feb-05 8:15
S. Senthil Kumar10-Feb-05 8:15 
GeneralRe: Client/Server Pin
Judah Gabriel Himango10-Feb-05 9:01
sponsorJudah Gabriel Himango10-Feb-05 9:01 
I will build a protocol using which the server and client will talk to each other.

No need, there are already protocols built in that allow one application to talk to another application. Here's an example of using .NET remoting and TCP channels to have a server talk to a client:

// this is the 1st project, SayHello.dll

public interface ISayHello
{
    public void SayHello();
}


// this is a 2nd project, Server.exe

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

...

// this is the server program that is a console application

static void Main(string[] args)
{
    // register a channel the client can talk to us on
TcpChannel channel = new TcpChannel(2600);
ChannelServices.RegisterChannel(channel);

    // create and publish a ServerSayHelloClass
    ServerSayHelloClass remoteObject = new ServerSayHelloClass();
    RemotingServices.Marshal(remoteObject, "Foobar.rem");

    // since this is a console app, wait for user input before exiting
    Console.ReadLine();
}

// make an ISayHello implementer. For this object to be remoted by reference, it must inherit from MarshalByRefObject
public class ServerSayHelloClass : MarshalByRefObject, ISayHello 
{

    public void SayHello()
    {
        Console.WriteLine("Hello!");
    }

    // return null if you want your remote object to live forever
    public override object InitializeLifetimeService()
    {
	return null;
    }
}


// this is a 3rd project, Client.exe

static void Main(string[] args)
{
    // connect to the server's published object
    ISayHello serverObject = (ISayHello)RemotingServices.Connect(typeof(ISayHello), "tcp://localhost:2600/Foobar.rem");

    // this will print something on the server!
    serverObject.SayHello(); 

    // if this is a console app, wait for user input before exiting
    Console.ReadLine();
}


So in summary, you probably want 3 projects: one project for your dll that will be shared among both client and server, a second project for you server, and a third project for your client.

Of course, the above example is very simple; you can do much much more with .NET remoting including creating your own channels, remoting more advanced objects, and so on. If you need more help, search google for .NET remoting.

Tech, life, family, faith: Give me a visit.
Judah Himango


GeneralRe: Client/Server Pin
Soumya Mulukutla10-Feb-05 9:46
Soumya Mulukutla10-Feb-05 9:46 
GeneralRe: Client/Server Pin
Judah Gabriel Himango10-Feb-05 9:59
sponsorJudah Gabriel Himango10-Feb-05 9:59 
QuestionDllImport() with flexible DLL name? Pin
mav.northwind10-Feb-05 6:41
mav.northwind10-Feb-05 6:41 
AnswerRe: DllImport() with flexible DLL name? Pin
Dave Kreskowiak10-Feb-05 6:52
mveDave Kreskowiak10-Feb-05 6:52 
AnswerRe: DllImport() with flexible DLL name? Pin
Phil Hobgen10-Feb-05 7:32
Phil Hobgen10-Feb-05 7:32 
GeneralRe: DllImport() with flexible DLL name? Pin
mav.northwind10-Feb-05 8:40
mav.northwind10-Feb-05 8:40 
GeneralCollections and ISerializable Pin
Clickok10-Feb-05 5:09
Clickok10-Feb-05 5:09 
GeneralFast Fourier Tarnsformation Pin
9-Feb-05 23:31
suss9-Feb-05 23:31 
GeneralRe: Fast Fourier Tarnsformation Pin
Jon Sagara10-Feb-05 6:00
Jon Sagara10-Feb-05 6:00 
GeneralCombo Box in Datagrid Cell Pin
Glaivas9-Feb-05 23:02
Glaivas9-Feb-05 23:02 
GeneralWMI Win32_Process Pin
skrishnasarma9-Feb-05 21:51
skrishnasarma9-Feb-05 21:51 
GeneralCapturing global keystrokes Pin
SnuhEyeless9-Feb-05 21:12
SnuhEyeless9-Feb-05 21:12 
GeneralRe: Capturing global keystrokes Pin
SnuhEyeless9-Feb-05 21:29
SnuhEyeless9-Feb-05 21:29 
GeneralRe: Capturing global keystrokes Pin
Stefan Troschuetz9-Feb-05 21:51
Stefan Troschuetz9-Feb-05 21:51 
Generalcreate a screen program same as like report from a xml file Pin
dhol9-Feb-05 19:35
dhol9-Feb-05 19:35 
GeneralRe: create a screen program same as like report from a xml file Pin
Dave Kreskowiak10-Feb-05 5:17
mveDave Kreskowiak10-Feb-05 5:17 
GeneralRe: create a screen program same as like report from a xml file Pin
dhol10-Feb-05 16:36
dhol10-Feb-05 16:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.