All pastes #434141 Raw Edit

Mine

public text v1 · immutable
·published 2007-04-11 07:42 UTC
rendered paste body
// project created on 01.04.2007 at 12:11
using System;
using System.Threading;
using System.Net;
using System.Net.Sockets;
namespace ObserverClient
{
	class MainClass
	{
		const string quit="quit";
		const string connect="connect";
		const string disconnect="disconnect";
		static string cmd;
		static TcpClient client;
		static Thread listenThread;
		
		public static void Main()
		{
	
			 cmd = Console.ReadLine();
			
		
		/*	while (cmd.ToLower()!=quit)
			{
				if (cmd.StartsWith(connect))
					Connect(cmd);
				if (cmd.Equals(disconnect))
					{
						System.Console.WriteLine("disconnecting...");
						client.Close();
						client=null;
					}
				else
					SendMessage(cmd);
				
				cmd=Console.ReadLine().ToLower();
			}*/
		}
		
//		private static void Connect(string command)
//		{
//			string[] param=command.Substring(connect.Length+1).Split(',');
//			try
//			{
//				int myPort=int.Parse(param[2]);
//				int port =int.Parse(param[1]);
//				string ip= param[0];
//				try
//				{
//				  string host=	Dns.GetHostName();
//				  
//				  IPHostEntry entry=Dns.GetHostEntry(host);
//				  
//				  IPAddress myaddress=IPAddress.Parse(entry.AddressList[0].ToString());
//				   	IPEndPoint myep=new IPEndPoint(myaddress,myPort);
//				 
//				   
//					client=new TcpClient(myep);
//				
//				 	IPAddress address=IPAddress.Parse(ip);
//				   	IPEndPoint ep=new IPEndPoint(address,port);
//				 
//					client.Connect(ep);
//
//					Console.WriteLine("Connected");
//					SendMessage("test mesajı clienttan");
//				
//					
//					listenThread= new Thread(new ThreadStart(Listening));
//					listenThread.Start();
//				}
//				catch (Exception ex)
//				{
//					Console.WriteLine("Bağlantı hatası");
//					Console.WriteLine(ex.Message);
//				}
//			}
//			catch (Exception ex)
//			{
//				Console.WriteLine("Geçersiz parametreler");
//				Console.WriteLine(ex.Message);
//			}
//		}
//		
//		private static void SendMessage(string command)
//		{
//			
//			if (!client.Connected)	
//				{
//					System.Console.WriteLine("Not connected!!");
//				return;
//				}
//			byte[] bytes=System.Text.Encoding.ASCII.GetBytes(command + "||");
//			NetworkStream stream;
//			stream= client.GetStream();
//			stream.Write(bytes,0,bytes.Length);
//
//		}
//		
//		private static void Listening()
//		{
//			while (true)
//			{
//				NetworkStream stream=client.GetStream();
//			byte[] bytes=new byte[1024];
//			stream.Read(bytes,0,bytes.Length);
//			
//			string msg=System.Text.Encoding.ASCII.GetString(bytes);
//			msg=msg.Trim(char.MinValue);
//			if (msg.Length==0)
//				{
//					client.Close();
//					client=null;
//					System.Console.WriteLine("Server closed the connection..");
//					return;
//				}
//				
//			System.Console.WriteLine(msg + " arrived from server to client");
//
//			}
//			
//		}
	}
}