Hello everyone,
NetFoss requires you to run it with a command line similar to this:
nf.bat /n[#] /h[#] [command line] where /n[#] is a node number and /h[#] is an OS socket handle.
I want to write something in C# very similar to what a telnet BBS would do when it runs door games. It should accept the client socket, gather a bit of information passed into it from the client, then pass the socket over to NetFoss to be used to run a DOS based application that supports communications via a fossil driver.
I honestly was just guessing about how to go about this, and here's what I came up with:
class Program
{
const int BACKLOG_SIZE = 20;
static void Main(string[] args)
{
Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
server.Bind(new IPEndPoint(IPAddress.Any, 3102));
server.Listen(BACKLOG_SIZE);
while (true)
{
Socket socket = server.Accept();
Process p = new Process();
p.EnableRaisingEvents = false;
p.StartInfo.FileName = @"c:\netfoss\nf.bat";
p.StartInfo.Arguments = @"/n1 /h" + socket.Handle + @" c:\game\game.bat 1";
p.StartInfo.WorkingDirectory = "c:\netfoss";
p.StartInfo.UseShellExecute = false;
p.Start();
}
}
}
Interestingly enough, the application that NetFoss is running via game.bat is being output to the C# application's console window but not the telnet client, and even more interesting is that the telnet client DOES receive the initial NetFoss message that shows it is able to communicate with the socket. So, why is the application that is passed to NetFoss outputting to my console window instead of the telnet client?
Anyone know what I'm missing?
EDIT:
I forgot to mention that I also tried setting UseShellExecute to TRUE, and this throws a NetFoss error saying that it is an invalid handle. From my understanding, I would have to duplicate the handle in some way so that the unmanaged application can access it? Is there any way to accomplish what I'm trying to do using C#?
Thanks, Marc