Click here to Skip to main content
Click here to Skip to main content
Articles » Languages » C# » General » Downloads
 

Notification Client and Server Written in C#

By , 22 Oct 2007
 
notifier.zip
info.ico
NotifyClient.exe
NotifyServer.exe
/*
 * Created by SharpDevelop.
 * User: sollw2
 * Date: 10/18/2007
 * Time: 1:54 PM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Net.Sockets;
using System.Text;

namespace NotifyClient
{
	class Program
	{
		public static void Main(string[] args)
		{
			
			// TODO: Implement Functionality Here
			if (args.Length != 6)
			{
				Console.Write("Usage: NotifyClient.exe host port timeout[milliseconds] icon[INFO|WARN|ERROR|NONE] title message\n\n");
				System.Environment.Exit(1);
			}
			StringBuilder myMessage = new System.Text.StringBuilder();
			myMessage.AppendFormat("{0}|{1}|{2}|{3}",args[2],args[3],args[4],args[5]);
			try
			{
				TcpClient client = new TcpClient();
				ASCIIEncoding encoder = new ASCIIEncoding();
				byte[] buffer = encoder.GetBytes(myMessage.ToString());
				client.Connect(args[0], Convert.ToInt16(args[1]));
				NetworkStream stream = client.GetStream();
				stream.Write(buffer, 0, buffer.Length);
				stream.Close();
				client.Close();
				Console.WriteLine("Message was sent to host " + args[0] + " on port " + args[1]);
			}
			catch(System.Exception e)
			{
				Console.WriteLine("Message was not sent");
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of use and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

About the Author

Helbrax
Web Developer
United States United States
Member
No Biography provided

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 22 Oct 2007
Article Copyright 2007 by Helbrax
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid