Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using MyClientServerLib;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace MyClientProgram
- {
- class ClientProgram
- {
- static string clientID = string.Empty;
- static string otherClientID = string.Empty;
- #region main
- static void Main(string[] args)
- {
- Console.Title = "Client 1";
- string host = "localhost";
- int port = 2000;
- ClientClass thisClient = new ClientClass(host, port);
- thisClient.Connect();
- thisClient.SendIdToServer();
- try
- {
- // Read in a secong thread.
- // Because, server will send very few messages.
- Thread thread = new Thread(delegate()
- {
- ClientClass.ReadFromServer(thisClient);
- });
- thread.Start();
- // Write in the main thread
- ClientClass.WriteToServer(thisClient);
- }
- catch
- {
- thisClient.Disconnect();
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement