This is Bananattack.

Raw Sockets and Sock Puppets

Posted by Overkill on April 17, 2008 at 2:09 pm under Uncategorized

Okay, so I just got home from another year of school. Now that summer’s here, there’s more time to work, and, more specifically, work on games again!

While this isn’t quite Resonance, I added some really awesome functionality to Verge for ustor’s space game.

A way for network sockets to connect to any port! What does this mean? It means that you can use Verge to do things besides just communicate with Verge! You can get it to do all sorts of neat things, like connect to simple websites (port 80), chat on IRC (port 6667 usually), download from FTP (port 21), the possibilities are really endless! This is the magic you get by adding a simple call to void SetConnectionPort(int port); before you int Connect(string ip);, simple stuff!

Only thing is a lot of servers only deal with plain-text messages, which string SocketGetString(int sock) and void SocketSendString(int sock, string message) can’t exactly do. Oh crap. So that means, the port switching was useless?

That means our lives are over.

Our dreams of making a web browser in Verge to compete with Opera, Internet Explorer and Firefox was crushed.

But wait! It’s not over yet! Raw string transfer saves the day and gets the girl again.

There’s two magical functions, like two pieces of an elaborate puzzle. When combined, babies are born — er, I mean — communication can be made between server and client.

First let me introduce you to the lady behind this operation. The super seductive string SocketGetRaw(int sock, int length)! They love the slurpy smooth strings the server gives them with raw relentless force. But only up to 4095 characters, let’s not get too crazy here, thanks.

Pair them with the agressive alpha male void SocketSendRaw(int sock, string message)! They throw violent string uppercuts with their violently raw knuckles and aren’t afraid to kick you in the packets. This sends strings back to the server!

Given the sexy and violent nature of raw socket transfer, it is now up to you, the user to know how these strings must be terminated.

For instance, IRC needs a carriage return ‘\r’ and line feed ‘\n’ after each packet, and also expects that your client will see each \r\n terminator as the end of a packet. But this isn’t too bad, when reading just buffer the string somewhere and loop until newlines are found in your string. And it’s especially easy for sending, just append \r\n onto the end.

Here’s a somewhat screwy screenshot, but it works. I think I screwed up the line display on this. But I can assert that it connects to an IRC channel and spews out: “<TheCoolestGuyEver> It worked. Woo!”

You can get it while it’s still hot and fresh from the Verge subversion repository!

Username: anonymous
Password: anonymous

I’ll be back with more exciting verge changes or Resonance action someday soon!



Tags: , ,

No comments (make one!)