Quantcast
Viewing latest article 4
Browse Latest Browse All 24

CTU Newhire Guide to Opening a Socket

NOTE: See this post for information on MySpace Account Hacking.

In FOX's 24, whenever Jack Bauer is in a pinch, resident techgeek Chloe O'Brien has to "open a socket" or "open up a socket to the server". What does it all mean?

Well, I've been doing "network programming" (i.e. writing software that uses the Internet) since the 90's (I even have a web site about it) and I'm here to set everyone straight.


Sockets, schmockets, what's the deal?

Just like a house has multiple phone numbers for multiple land-lines (in a chatty house, one for uncle Bob, one for little Jimmy, one for grandma, etc.), a computer has multiple numbered "ports". For example, port 80 is often used for web sites.

When you make a phone call, you just pick up the phone and call someone's number. With computer "ports", you can't just contact a port on someone's computer -- they also have to be "listening" on that port. The way I think about it, the moment you plugin your phone handset into the wall, your phone is "listening". This web site you're reading right now has a web server program that is "listening" on port 80.

So how did your computer "call" this web site to download this page that you're reading right now?

Believe it or not, but the first thing it did was "open a socket". I kid you not.

Opening a socket is basically like picking up the phone handset to hear the dialtone. It's all just software bookkeeping on your local computer, until the next step:

The next thing your computer (your browser, really) did, was to "connect" that open socket to the listening port on my web site. This is basically the equivalent of connecting the phone call.

Once the socket connection is made, data can be transferred both ways. i.e. your computer requests a specific page, then this web site sends the page.


Socket Cheatsheet

To summarize:

  • Phone number = computer port number
  • Plugging in phone handset into wall = program listening on a port
  • Picking up the phone handset = opening a socket
  • Dialing the phone = connecting the socket

So what does the show really mean when they open a socket?

My guess is that the writers wanted something cryptic sounding, yet still based in reality. The good thing about using the phrase "socket" is that because sockets are fairly "low level", they don't really imply anything about what you do with them, in the same sense that who knows what people do with phones (i.e. ask for Mom's apple pie recipe, or find the hours of a store, etc.).

Of course, now that I've explained what "opening a socket" is, it just isn't as cryptic anymore. I'd suggest to the writers that they try something even more cryptic, yet still based in reality like this:

CTU newbie: I can't get it to work.
Chloe: You probably forgot to bind your socket.
(Chloe shoots the newbie that"lamer" look.)


Who wants to open a socket?

Everyone who uses the Internet opens up plenty of sockets, but it's all sort of hidden with complex software like browsers, etc. Anyone like Chloe would do something way more hardcore like... before I ramble on, does anyone want to see how to do these things hardcore? Drop me a comment and I'll write-up another part to this guide.


A Note to Hardcore Socket Programmers

Before someone comes down from Division or the Department of Homeland Security to escort me away, yes, I've omitted tons of details above like: IP addresses, binding, the socket used for listening, the socket returned from accept(), TCP vs. UDP, HTTP, protocols, how TCP works, etc., etc. Though I did try to use terminology like "listen" and "connect" based on the BSD socket APIs of the same names.


Viewing latest article 4
Browse Latest Browse All 24

Trending Articles