|
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace SteganoFTP
{
public class SessionManager
{
private const int FTP_COMMAND_PORT = 42; //21;
private bool isRunning;
private Socket mainServerSocket;
public SessionManager()
{
OpenLocalSocket();
Thread mainServerThread = new Thread(new ThreadStart(Listen));
mainServerThread.Start();
}
private void OpenLocalSocket()
{
IPHostEntry localHostEntry = Dns.GetHostEntry(Dns.GetHostName());
IPEndPoint endPoint = new IPEndPoint(localHostEntry.AddressList[0], FTP_COMMAND_PORT);
this.mainServerSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
this.mainServerSocket.Bind(endPoint);
Console.WriteLine("Waiting on Port {0}", endPoint.Port.ToString());
}
private void Listen()
{
this.isRunning = true;
string remoteServerName = System.Configuration.ConfigurationSettings.AppSettings["ftpServerName"];
int remoteServerPort = int.Parse(System.Configuration.ConfigurationSettings.AppSettings["ftpServerPort"]);
try
{
while (this.isRunning)
{
// accept for connection
this.mainServerSocket.Listen(10);
Socket socketToClient = this.mainServerSocket.Accept();
CommandChannelSocketSet sockets = new CommandChannelSocketSet(socketToClient, remoteServerName, remoteServerPort);
}
this.mainServerSocket.Close();
}
catch (SocketException ex)
{
Console.WriteLine("Socketfehler: {0}", ex.ToString());
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service 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.