Here's my contribution to the Code Exchange. For this, I'm going to tell you how you can make RealBasic do fun stuff with networking.
I'm hoping for this to be the most extensive and easiest-to-understand networking tutorial out there, so enjoy reading it.
Introduction notesI know what you're thinking; "I haven't used RealBasic since I was 12. RealBasic guys aren't real programmers, dude!".
This goes against the whole idea of technology. Technology is supposed to be an ever moving high speed train; it only goes forward. You could be sitting there writing the exact same program we're going to make in C and thinking you're cool because it's what software engineers use, but RealBasic (and most OOP people) can make applications in a quarter of the time it takes traditional interprelites (my name for those who like to write code in one continuous scroll) to get the very foundations of their programs fully set.
RealBasic is also good for compiling cross platform. For example, we could write a text editor in C, compile it for Mac, and then you'd probably have to restructure the same application to make it work on Windows. RealBasic handles that for you, so you can spend more time working on the actual application and adding features and capabilities rather than buggering about with funny system calls.
Java is the exception, but unless you don't want your code to be easily viewed by absolutely everyone in the world, I would advise keeping your good ideas in a language that you know is difficult to reverse engineer or crack into.
This is just an introductory note for those who are wondering why the hell I'm making a post for RealBasic, as I know there are a lot of interprelites out there who will make
any justification to call RealBasic a piece of crap.
You will need...A pen and a large amount of paper. Make sure you are alone in an empty, comfortable environment. Preferably, you'd have a dry-wipe board, a shirt, a tie and, of course, multi-coloured pens.
You'll also need some Red Bull, Pepsi, coffee - take your pick. Snacks are fine as well, just don't choose chocolate or anything overly salty. Cigarettes are also a recommendation. I shouldn't advocate smoking and I'm sure it must be fun being smoke-free, but I swear to god, if you want to survive network programming
without self harming, you're going to require twenty Lucky Strikes and a Zippo.
Rootle through your CD collection and find some good tunes. Something you can just slap on as a backing track for thinking; I personally recommend the B-52s or Lemon Jelly.
Put on your CD of choice, open up that tin of soda and prepare yourself for the most uncomfortable day of your life.
Finally, open up your
probably pirated copy of RealBasic, and we can REALLY begin.
So, what now?Well, we're going to make an instant messaging program. Sounds hard; but thankfully, RealBasic makes it easy.
Now, let's just talk about sockets. No, not the ones in your head; SOCKETS. Those lovely little things that make the internet possible and the thing that makes the sun rise in the morning and set in the evening.
There are two kinds of protocols we care about; TCP and UDP.
TCP is what REALLY makes the sun rise in the morning. It's reliable, it powers practically every computer's networking capabilities, and it's an absolute asshole to work with. It's a connection orientated protocol, so we have to connect to the other side before we can send any data. It requires more preparation than UDP, but you get reliability and stability that data is received securely.
UDP stands for User Datagram Protocol. It's a connectionless protocol which requires next to no preparation; you just enter in an IP, and the data gets sent. It doesn't do any confirmation nor any reliability tricks, which is useful for sending little bits of data; however, this notoriety has earned UDP the nickname
Unreliable Datagram Protocol. Over a local network, it's fine. Internet? I wouldn't.
So, what will we use? We'll use the easiest object to make our IM program work; the AutoDiscovery socket. Open up Window1, and give it the title 'Chatroom', or whatever you want. Drag in a base object and rename the Super as "AutoDiscovery" without quotes. You'll want to rename it to "ChatroomConnector" so we can keep track of what the object's name is.
Next, choose a port to send to. In the properties of this new control, make sure 'SendToSelf' is ticked, and choose a lovely open and free port to use (for example, you could choose port 8080).
Now, drag in two edit fields and a push button. Rename your large edit field to "ChatLog" and the other, preferably smaller edit field to "ChatString". Oh, you'll need to change the caption of that push button to "Send" and the name of that button to "SendMessage". Make sure the larger editfield has the MultiLine property set to true (hint: it's that little checkbox in the properties section!)
To give it a little bit of tidyness, we'll want to change the font size of the larger ChatLog to 10, and maybe change the font.
Now, let's take a look at what we have here.
Sweet! We do indeed have the makings of an IM application. Go and reward yourself; have a cigarette, make a coffee, do whatever. We are not at the complicated bit. Yet.