Sunday, January 08, 2006

PVP Server Recoded In C

So, I've been fiddling with the PVP server a bit, and was trying to work out a way for me to run it when I arrive back at Uni (where I now am). The only boxes at home that I'm happy to leave on all the time with little fear of them dying on me are Linux boxes.


Linux doesn't run VB programs very well.


Enter, one crash course in C Network Programming (we havent even touched on this in Uni). I was suprised how difficult it was to find any decent info on even a standard network program.

When I finally got a basic server running that performs the same initial jobs as the VB PVP server, I realised that I needed to be able to make it talk to a MySQL server. More research! All the tutorials I found wouldnt compile, so I ended up frantically emailing the author of one for some more assistance...

Of course, I needed to compile my program with "-I/usr/include/mysql -L/usr/lib/mysql -lmysqlclient -lz" options for the gcc command... Why didnt I think of that? ;)

So, the server is sitting at a semi-completed state, with one major problem... To enable the server to keep recieving connections while dealing with existing connections, the program "forks", e.g, makes a copy of itself, and the copy handles the new connection. The original continues to wait for new connections. So, if I log someone in with the copy, and store some information in a variable, the original copy will never know about the contents of this variable, because it exists only in the copy.

I have no idea how to get around this, so, anyone familiar with C, and the fork() command, along with network programming and arrays, please get in touch!

1 comment:

welterde said...

or try Interprocess-communication like Pipes, but Threads are more performent than Forks. You may want to use a combined methods. Threadpools and such stuff.