tags:

views:

66

answers:

1

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

+1  A: 

Hi Marc,

It is normal that the DOS application outputs to your console window, but it should also output to the telnet client.

Since you are seeing the initial NetFoss version message in your telnet client, we know that the socket handle is being sucesfully passed to NetFoss... So it sounds like the problem is that your DOS application is not FOSSIL aware, or is not currently configured to use a FOSSIL or an INT14h communications method.

Regards, Mike NetFoss developer

I apologize for not updating this sooner, but it seems that it was working all along. The hang up I was having is that I was building a telnet client in Flash, and since it was cross-domain, it was first doing a connect and passing cross-domain policy request before being allowed to connect fully. I just added the code to handle the two different scenarios prior to passing off the connection and everything worked as expected. But thanks for the response! :)
Lusid