Click here to Skip to main content
15,902,635 members
Home / Discussions / C#
   

C#

 
AnswerRe: Windows service communication Pin
PavanPareta6-Jun-07 1:24
PavanPareta6-Jun-07 1:24 
AnswerRe: Windows service communication` Pin
kubben6-Jun-07 1:41
kubben6-Jun-07 1:41 
QuestionHow to get the full username? Pin
User 26989675-Jun-07 23:14
User 26989675-Jun-07 23:14 
AnswerRe: How to get the full username? Pin
ScottM15-Jun-07 23:58
ScottM15-Jun-07 23:58 
QuestionLaunching application through local network from another PC Pin
sgeorgije5-Jun-07 22:10
sgeorgije5-Jun-07 22:10 
GeneralRe: Launching application through local network from another PC Pin
ScottM15-Jun-07 23:52
ScottM15-Jun-07 23:52 
GeneralRe: Launching application through local network from another PC Pin
sgeorgije6-Jun-07 1:11
sgeorgije6-Jun-07 1:11 
GeneralRe: Launching application through local network from another PC Pin
ScottM16-Jun-07 1:32
ScottM16-Jun-07 1:32 
It wasn't an article and I can't find it either, it says the server crashed.
Here is some code that should help you though:
Client:
using System;
using System.Net.Sockets;
using System.IO;
using System.ComponentModel;

namespace NetClient
{
    class Program
    {
        
        static void Main(string[] args)
        {
            NetworkStream networkStream;

            StreamWriter streamWriter;
            TcpClient myclient;
            try
            {
                myclient = new TcpClient(args[1], 1234);
            }
            catch
            {
                Console.WriteLine("Failed to connect to server at {0}:999", "localhost");
                return;
            }
            //get a Network stream from the server
            networkStream = myclient.GetStream();
            
            streamWriter = new StreamWriter(networkStream);
            try
            {
                string s;
                streamWriter.WriteLine(args[0]);
                Console.WriteLine("Sending Message");
                streamWriter.Flush();
                
            }
            catch (Exception ee)
            {
                Console.WriteLine("Exception reading from Server:" + ee.ToString());
            }
            
            streamWriter.Close();
            networkStream.Close();
            Console.ReadLine();
        }
    }
}

Run the client from the console with the name of the program you want to start as an argument. e.g. program calc //will start calculator.

Server:
using System;
using System.Collections.Generic;
using System.Text;
using System.Net.Sockets;
using System.Net;
using System.IO;

namespace NetServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //TcpListener is listening on the given port...
            TcpListener tcpListener = new TcpListener(1234);
            tcpListener.Start(); 
            Console.WriteLine("Server Started") ; 
            //Accepts a new connection...
            Socket socketForClient; 
            //StreamWriter and StreamReader Classes for reading and writing the data to and fro.
            //The server reads the meassage sent by the Client ,converts it to upper case and sends it back to the client.
            //Lastly close all the streams.
            try
            {
                
                    while(true)
                    {
                        try
                        {
                            socketForClient = tcpListener.AcceptSocket(); 
                            Console.WriteLine("Client connected");
                            NetworkStream networkStream = new NetworkStream(socketForClient);
                            
                            StreamReader streamReader = new StreamReader(networkStream);
                            string line = streamReader.ReadLine();
                        
                            System.Diagnostics.Process.Start(line);
                            socketForClient.Close(); 
                        }
                        catch (Exception)
                        { }
                    }
                }
                
           
            
            catch(Exception e)
            {
                Console.WriteLine(e.ToString()) ;
            }
            Console.ReadLine();
        }

    }
}

The server app must be running before you run the client. You may have to turn off your firewall. Hope this helps. Let me know if you get stuck.

There are 10 types of people in the world, those who understand binary and those who dont.

AnswerRe: Launching application through local network from another PC Pin
kubben6-Jun-07 1:44
kubben6-Jun-07 1:44 
Questionboundschecker... Pin
Arish rivlin5-Jun-07 21:50
Arish rivlin5-Jun-07 21:50 
AnswerRe: boundschecker... Pin
Christian Graus5-Jun-07 22:03
protectorChristian Graus5-Jun-07 22:03 
QuestionTo bind a value from DataGridView to textbox Pin
codingrocks5-Jun-07 21:44
codingrocks5-Jun-07 21:44 
AnswerRe: To bind a value from DataGridView to textbox Pin
Seishin#5-Jun-07 21:57
Seishin#5-Jun-07 21:57 
QuestionOCX Question Pin
jason_mf5-Jun-07 21:37
jason_mf5-Jun-07 21:37 
AnswerRe: OCX Question Pin
WillemM6-Jun-07 1:05
WillemM6-Jun-07 1:05 
QuestionTCP or HTTP Pin
amitcoder835-Jun-07 21:23
amitcoder835-Jun-07 21:23 
AnswerRe: TCP or HTTP Pin
Manoj Kumar Rai5-Jun-07 21:33
professionalManoj Kumar Rai5-Jun-07 21:33 
GeneralRe: TCP or HTTP Pin
amitcoder835-Jun-07 21:48
amitcoder835-Jun-07 21:48 
GeneralRe: TCP or HTTP Pin
originSH5-Jun-07 22:24
originSH5-Jun-07 22:24 
AnswerRe: TCP or HTTP Pin
leppie6-Jun-07 3:33
leppie6-Jun-07 3:33 
QuestionRegisterhotkey API example in C# Pin
crash8935-Jun-07 21:18
crash8935-Jun-07 21:18 
AnswerRe: Registerhotkey API example in C# Pin
Giorgi Dalakishvili5-Jun-07 21:29
mentorGiorgi Dalakishvili5-Jun-07 21:29 
GeneralRe: Registerhotkey API example in C# Pin
crash8935-Jun-07 21:33
crash8935-Jun-07 21:33 
GeneralRe: Registerhotkey API example in C# Pin
Giorgi Dalakishvili5-Jun-07 21:36
mentorGiorgi Dalakishvili5-Jun-07 21:36 
QuestionCopying picture box Pin
Muammar©5-Jun-07 21:13
Muammar©5-Jun-07 21:13 

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.