raw TCP communication with mysql server

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
Where can I get some documentation on how the mysql protocol works? I'd like to write a class that can connect directly to a server and talk to it, this way I can bypass any libraries and other stuff, and just do it directly. At least, if it's not too complicated. this will save me from getting libraries to work reliably on different platforms.

For example, on one distro I can get my mysql++ app to compile, on another distro, it wont, who knows what other surprises I'll get elsewhere or if I even manage to fix it. I want something that will just work universally with zero hassle. Hopefully the tcp protocol is consistent from version to version, though.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Just figure out what you're doing wrong with those libraries and use them, having yet another implementation of a free protocol with so many implementations already is just a bad idea.
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
Thats the thing, why spend hours, if days, trying to figure out why it wont compile or run, when I can just do my own library that will work each time? I'll have to compile differently under each distro for it to work with a library, if I make my own header file, no need to link or do anything special, just an include. It will also make things faster as it removes a layer of complexity.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Thats the thing, why spend hours, if days, trying to figure out why it wont compile or run, when I can just do my own library that will work each time?

Do you really think you can implement the MySQL protocol 100% correctly the first time? You're going to end up spending much more time developing your library than figuring out what you did wrong using the other library. Hell I can't remember a time when having a dev package installed didn't include everything I needed to compile something against that library. It's probably something really simple that you're missing.

I'll have to compile differently under each distro for it to work with a library, if I make my own header file, no need to link or do anything special, just an include. It will also make things faster as it removes a layer of complexity.

It won't be any faster and whenever there's security issues and updates to the protocol your library will break. Instead of just maintaining your app you'll be maintaining yet another implementation of the MySQL protocol for no good reason.
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
I'd still like to learn how to do it though. Imagine a single .h or a set of .h files that you pop into any program and lets you use SQL from any OS that supports C++ without having to do anything special at compile time. No dependancies, nothing, it just works. Would be a beauty. Sure it may not be easy, but if I can at least get a detailed spec of the protocol I can decide for myself if I want to take this on. I did found some protocol info but don't know how old it is.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I'd still like to learn how to do it though. Imagine a single .h or a set of .h files that you pop into any program and lets you use SQL from any OS that supports C++ without having to do anything special at compile time. No dependancies, nothing, it just works. Would be a beauty. Sure it may not be easy, but if I can at least get a detailed spec of the protocol I can decide for myself if I want to take this on. I did found some protocol info but don't know how old it is.

No, it wouldn't be a beauty because the code already exists. Using the MySQL client libraries and their header files is an infinitely better solution. All you need to do is figure out how to link against them properly.

What you're describing is like static linking only worse because not only are you statically including the protocol implementation in your binary but you're writing it yourself from scratch for no good reason.
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
oh I got the library to link after a few hours. But see, this program I'm working on needs to be deployable in seconds. Basically it's a control panel. I need to be able to order a new server from a provider, upload the tar.gz, extract run ./rebuild then ./programname -setup run through wizard, then boom, hosting server is setup and fully working.

I'll also be releasing it to public, so I want to make it as noob friendly as possible. This is an issue with linux, installing stuff is never easy unless the package is in the official repositories. I want to make my program easy to deploy.

I agree 100% what you're saying though, I should use what's already available, and probably will end up doing it considering I already started to code with this library, but I at least want to try coding my own and see how far I get.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Honestly how hard is it to preinstall the mysql headers on each system? Assuming you are using a distro like debian or centos I dont' see why it would be that hard.
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
installing stuff in Linux is usually hit or miss. On some distros it might go smooth, others not, some will need dependencies, some will simply not work without having to manually move libraries around, there will always be something. Consistency would be a beautiful thing.

Like when I moved my application from CentOS to FC10, I had to fiddle around for a few hours until it worked as I had to google errors for a while to find out what to do. I want to avoid having to go through these steps every time.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
But see, this program I'm working on needs to be deployable in seconds.

I can't imagine time is that important and sacrificing security and maintainability for that isn't a good trade off.

installing stuff in Linux is usually hit or miss. On some distros it might go smooth, others not, some will need dependencies, some will simply not work without having to manually move libraries around, there will always be something. Consistency would be a beautiful thing.

Installing stuff in Linux is almost always simple for me. You should never have to move libraries from packages around. As long as you create a package for each distribution that you want to support and then make the source available for everyone else it's their choice. If they don't want to use a distro that you tested on and packaged for then let them deal with compiling it.

Like when I moved my application from CentOS to FC10, I had to fiddle around for a few hours until it worked as I had to google errors for a while to find out what to do. I want to avoid having to go through these steps every time.

I can't imagine it taking a few hours to figure out what other packages you needed to install.
 

Fallen Kell

Diamond Member
Oct 9, 1999
6,249
561
126
Have you ever heard of a static compile? You can do a static build of your application as long as you have all the library files you use with a static version (i.e. ".a" instead of ".so") and then the binary that is created contains ALL the dependent library files and code. Sure it will be a lot bigger, but no dependencies on anything.

But if you are doing this and releasing something which they have to compile, well you are just going to have to say you need XYZ to compile this application. I'm a system administrator. I jump through the hoops of getting XYZ installed all the time on platforms to support something. That is just what has to happen. No way around that.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Have you ever heard of a static compile? You can do a static build of your application as long as you have all the library files you use with a static version (i.e. ".a" instead of ".so") and then the binary that is created contains ALL the dependent library files and code. Sure it will be a lot bigger, but no dependencies on anything.

Which is only a slightly less bad idea than the one he started the thread with.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
Most good makefiles tend to check all the dependancies for you. And once they are done it is trivial to install the stuff they complain about.
 

Fallen Kell

Diamond Member
Oct 9, 1999
6,249
561
126
Originally posted by: Nothinman
Have you ever heard of a static compile? You can do a static build of your application as long as you have all the library files you use with a static version (i.e. ".a" instead of ".so") and then the binary that is created contains ALL the dependent library files and code. Sure it will be a lot bigger, but no dependencies on anything.

Which is only a slightly less bad idea than the one he started the thread with.

I agree with you on this one Nothinman, but at least it is better than him trying to make his own code to talk to mysql...
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
How would I staticly compile in g++? That may be an option. Will that also mean my app will work on ANY linux distro? That would be a God send. Sometimes I want to release an app or use one of my own apps and it's just so much simpler to have 1 binary then the entire source code being needed.
 

sourceninja

Diamond Member
Mar 8, 2005
8,805
65
91
-static flag

No it is not going to work on every linux distro. But it will work on a majority of them in most cases. It is still a bad idea. Proper make files and dependancy listings is a better way to go. The best would be building packages for the distros you want to support.
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
If it's so hard to do it the right way why have so many people been able to do it time and time again?
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
It's a convenience thing, and what if I don't want to make my program open source? Maybe I just want to release a binary and not have to worry about seeing 30 different clones of my program come out 5 days later.

Though more often what happens is I code an utility that I'll use on multiple systems. If I can save myself from having to compile it on each system it will save lot of time and headaches. Not all my servers are setup for development.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
It's a convenience thing, and what if I don't want to make my program open source? Maybe I just want to release a binary and not have to worry about seeing 30 different clones of my program come out 5 days later.

Then you need to look at the license of each library that you use, if one of them is GPL then you have no choice but to release your code as GPL as well.

Though more often what happens is I code an utility that I'll use on multiple systems. If I can save myself from having to compile it on each system it will save lot of time and headaches. Not all my servers are setup for development.

Then create a binary package, there's absolutely no reason that each of your sytems have to have development tools installed...
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Originally posted by: Nothinman
It's a convenience thing, and what if I don't want to make my program open source? Maybe I just want to release a binary and not have to worry about seeing 30 different clones of my program come out 5 days later.

Then you need to look at the license of each library that you use, if one of them is GPL then you have no choice but to release your code as GPL as well.

Though more often what happens is I code an utility that I'll use on multiple systems. If I can save myself from having to compile it on each system it will save lot of time and headaches. Not all my servers are setup for development.

Then create a binary package, there's absolutely no reason that each of your sytems have to have development tools installed...

Especially on production servers. :thumbsup:
 

Red Squirrel

No Lifer
May 24, 2003
71,325
14,089
126
www.anyf.ca
How would a binary package work? I thought that was just, releasing the binary? Like in windows you compile to .exe then you can release just the .exe.

Licensing is another reason I want to go away from libraries. If I code everything myself then no need to worry about any kind of restrictions, or companies going under, etc. Self sufficient FTW.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
How would a binary package work? I thought that was just, releasing the binary? Like in windows you compile to .exe then you can release just the .exe.

No, a binary package is a .deb, .rpm, etc. If it's done properly the dependency information will be provided and the user can just make sure they have the appropriate libraries installed beforehand.

Licensing is another reason I want to go away from libraries. If I code everything myself then no need to worry about any kind of restrictions, or companies going under, etc. Self sufficient FTW.

Waste of time FTL.