Linux – Transfert a file to a remote host with a particular port

The “scp” command is used to transfert file to a remote host.
The “-P” argument is used to define a particular port.

scp -P [port] path/to/local/file username@remote.host:~/remote.file
Advertisements

C# – Basic Server class – Using TCPListener

A basic server in C#

See ClientHandler

class Server
{
 private const int local_port = 5000;
 private TcpListener listener;

 public void start()
  {
   listener = new TcpListener( local_port);
   listener.Start();
   Console.WriteLine("Server started; listening on port " + local_port);

   while (true)
   {
     Socket clientSocket = listener.AcceptSocket();
     Console.WriteLine("Client connected : " + clientSocket.RemoteEndPoint);

     ClientHandler clientHandler = new ClientHandler(clientSocket);
     Thread clientThread = new Thread(clientHandler.start);
     clientThread.Start();
   }
  }
 }