www.digitalmars.com         C & C++   DMDScript  

D - any ideas?

[if you only care about d, you don't need to read this]
I have to do this: a distributed application, where the client (a windows
app) must receive commands from the server (a linux app). Both the client
(already written in D) and the server (in C, I didn't have any other choice)
must start with the OS, and only stop running when the OS shuts down. The
server is asynchronous (sp?) and should have some sort of control panel (if
it's graphical, it's a plus) where the system admin could control the
clients. I'm thinking that the control panel could be also a client, but
with a special configuration. I mean, when a client connects, it must notify
it it's a client or the CP. So far, no problem for me.
Now comes the good things. My server is being implemented modifying a talk
server (that's when you know it's important to pay attention in class...)
and it doesn't save any information about its clients. What's the best
option to do this? I was thinking having an array of a struct like this:
struct arr { int cliSock,isCP; char IP[15]; };
And it could work. But is it the best option?
Now let's consider this: the system admin wants a client to run a command,
and wait for it to finish. But s/he also wants to send a file to every
active client (an AV update, let's say). (All this assuming that, somehow,
the CP already knows what clients are connected). Well, the server receives
something like this from the CP: "w SomeMachine notepad" (tell SomeMachine
to run notepad and wait for it). Then receives "0" (what notepad returned)
and "s * update.av" (send to every machine the file update.av). It's easy to
know what comes from the CP, but how does the server know what comes from
which client? The real question is: how can the server store what every
client should send back? (if it must do it. For example, executing a command
w/o waiting won't return anything)
I also have to make the server run as a daemon, but I should be able to
tackle that.
A client issue: the server won't necessarily run on the same machine (at
least I think so) and the client doesn't have to tell the user anything.
Considering both things, how can I tell the clients where to look for the
server? I was thinking about this: a small program that would run only after
the installation, where it would ask the user where the main server is, and
save it to a file. Besides, the server could send a comand like: "n
IPAddress" (new server   IPAddress), so the client would add it to its file.
And when the client starts, it would check for that file and look for every
server on it. But what if someone decides to change the network
configuration? S/he would have to change the file for every client. Not so
good, is it?
What should happen if suddenly the server has to shut down or reboot? I
mean, what should the clients do? Now, theorically (I haven't checked this
feature yet) the clients should look for a server every 5 min if they're not
connected. Is it the right option? Because I was thinking, what if the
server notified every client that it has returned? The problem would be how
can the server know what clients are running (because, again, someone could
change the network config. Let's say, they buy a new computer. The server
doesn't know about this new client). Broadcasting? But in what range? Every
address from 0.0.0.0 (if it exists) to 255.255.255.255? That doesn't sound
sensible.
Besides, what's the best choice for the CP? Kylix? (know a bit) QT? (don't
know how to make it work) php? (don't know anything) JavaScript? (know a
bit. is it safe enough?).
I hope I'm not abusing with this, but I need a couple of ideas to finish it.
Any help would be greatly appreciated. Thanks in advance.

PS: by the way: I wanted to make the client also in C, but I couldn't get
read() and write() work properly, so I dropped that. I don't want anything

VB. I wanted to get as low as possible and that's why I chose C at the
beginning. With that small introduction, is C+D the best combo for the whole
application? Remember: except for the CP, nothing has an interface. Talking
about that: do Win9x and Me have the "start" command? If they don't, any
other way to run a program in background mode? (I was thinking "start /b
myprog"). Thanks again.

-------------------------
Carlos Santander
Apr 07 2003