• Complain

Jesse Storimer - Working With TCP Sockets

Here you can read online Jesse Storimer - Working With TCP Sockets full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2012, publisher: Jesse Storimer, genre: Computer / Science. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Jesse Storimer Working With TCP Sockets
  • Book:
    Working With TCP Sockets
  • Author:
  • Publisher:
    Jesse Storimer
  • Genre:
  • Year:
    2012
  • Rating:
    5 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 100
    • 1
    • 2
    • 3
    • 4
    • 5

Working With TCP Sockets: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Working With TCP Sockets" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Book DescriptionDo you know how your web server opens a socket, binds to an address, and accepts a connection? I did a lot of web programming before I had enough knowledge to dig in and figure this stuff out. I knew that other developers had a better grasp on the full stack than I did, but diving deep under the hood is one of the things that really made me a better developer all around. I recently read a great thread that asked What did the really successful programmers do differently?. This response really caught my eye: Be ready, willing, & able to deep dive multiple levels at any time. You must know whats going on under the hood. There is a strong correlation between number of levels of deepness understood and programming prowess. In this book Ill teach you these fundamentals using Ruby. Ill start with the fundamentals that are portable to any environment. Then Ill show you the beautiful abstractions that Ruby has layered on top of them. Learning this stuff doesnt just apply to Ruby, or any other language. Every modern programming language has support for networking. Every language has their own way of doing things. But all modern languages support the Berkeley Sockets API. Ruby is no exception. Theres certainly plenty of syntactic sugar, but below the sugar you can use the same Sockets API that you would in C, Java, Python, whatever. This is portable knowledge that will serve you for many years to come. What youll learn: The steps in the lifecycle of servers and clients. The various ways that we can read and write data in Ruby, and when theyre appropriate. All the things you were never quite sure about: EOF, listen queues, TCPNODELAY, and tons more. The low level methods required for constructing sockets, as well as the syntactic sugar that Ruby provides. Known methods that will help you improve socket performance. Basics of SSL sockets. Should you write a lot of data at once or chunk it into smaller writes? Get comfortable with the socket programming API thats available in any modern programming language. More example code than you shake a stick at! A look at 6 different architecture patterns for building concurrency into your network programs. A closer look at a few different protocols: FTP and Redis. Multiplexing connections, non-blocking IO, socket timeouts, socket options, and more

Jesse Storimer: author's other books


Who wrote Working With TCP Sockets? Find out the surname, the name of the author of the book and a list of all author's works by series.

Working With TCP Sockets — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Working With TCP Sockets" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Releases
  • October 24, 2012 - Initial public release.
Introduction

Sockets connect the digital world.

Think for a minute about the early days of computing. Computers were something used exclusively by the scientists of the day. They were used for mathematical calculations, simulations; Real Serious Stuff.

It was many years later when computers were able to connect people that the layperson became interested. Today, there are far more computers being used by laypeople than by scientists. Computers became interesting for this group when they could share information and communicate with anyone, anywhere.

It was network programming, and more specifically the proliferation of a particular socket programming API that allowed this to happen. Chances are, if you're reading this book, then you spend time every day connecting with people online and working with technology built on the idea of connecting computers together.

So network programming is ultimately about sharing and communication. This book exists so that you can better understand the underlying mechanisms of network programming and make better contributions to its cause.

My Story

I remember my first interaction with the world of sockets. It wasn't pretty.

As a web developer I had experience integrating with all kinds of HTTP APIs. I was accustomed to working with high-level concepts like REST & JSON.

Then I had to integrate with a domain registrar API.

I got a hold of the API documentation and was shocked. They wanted me to open a TCP socket on some private host name at some random port. This didn't work anything like the Twitter API!

Not only were they asking for a TCP socket, but they didn't encode data as JSON, or even XML. They had their own line protocol I had to adhere to. I had to send a very specifically formatted line of text over the socket, then send an empty line, then key-value pairs for the arguments, followed by two empty lines to show the request was done.

Then I had to read back a response in the same way. I was thinking "What in the...".

I showed this to a co-worker and he shared my trepidation. He had never worked with an API like this. He quickly warned me: "I've only ever used sockets in C. You have to be careful. Make sure you always close it before exiting otherwise it can stay open forever. They're hard to close once the program exits".

What?! Open forever? Protocols? Ports? I was flabbergasted.

Then another co-worker took a look and said "Really? You don't know how to work with sockets? You do know that you're opening a socket every time you read a web page, right? You should really know how this works."

I took that as a challenge. It was tough to wrap my head around the concepts at first, but I kept trying. I made lots of mistakes, but ultimately completed the integration. I think I'm a better programmer for it. It gave me a better understanding of the technology that my work depends upon. It's a good feeling.

With this book I hope to spare you some of that pain I felt when I was introduced to sockets, while still bringing you the sweet clarity that comes with having a deep understanding of your technology stack.

Who is This Book For?

The intended audience is Ruby developers on Unix or Unix-like systems.

The book assumes that you know Ruby and makes no attempts to teach Ruby basics. It assumes little to no knowledge of network programming concepts. It starts right at the fundamentals.

What to Expect

This book is divided into three main parts.

The first part gives an introduction to the primitives of socket programming. You'll learn how to create sockets, connect them together, and share data.

The second part of the book covers more advanced topics in socket programming. These are the kinds of things you'll need once you get past doing 'Hello world'-style socket programming.

The third part applies everything from the first two parts of the book in a 'real-world' scenario. This section goes past just sockets and shows you how to apply concurrency to your network programs. Several architecture patterns are implemented and compared to solve the same problem.

The Berkeley Sockets API

The main focus of this book will be the Berkeley Sockets API and its usage. The Berkeley Sockets API first appeared with version 4.2 of the BSD operating system in 1983. It was the first implementation of the then newly proposed Transport Control Protocol (TCP).

The Berkeley Sockets API has truly stood the test of time. The API that you'll work with in this book and the one supported in most modern programming languages is the same API that was revealed to the world in 1983.

Surely one key reason why the Berkeley Sockets API has stood the test of time: You can use sockets without having to know the details of the underlying protocol. This point is key and will get more attention later.

The Berkeley Sockets API is a programming API that operates at a level above the actually protocol implementation itself. It's concerned with stuff like connecting two endpoints and sharing data between them rather than marshalling packets and sequence numbering.

The de facto Berkeley Sockets API implementation is written in C, but almost any modern language written in C will include bindings to that lower-level interface. As such, there are many places in the book where I've gone to the effort of making the knowledge portable.

That is to say, rather than just showing the wrapper classes that Ruby offers around socket APIs I always start by showing the lower level API, followed by Ruby's wrapper classes. This keeps your knowledge portable.

When you're working in a language other than Ruby you'll still be able to apply the fundamentals you learn here and use the lower level constructs to build what you need.

What's Not Covered?

I mentioned in the last chapter that one of the strengths of the Berkeley Sockets API is that you don't need to know anything about the underlying protocol in order to use it. This book heartily embraces that.

Some other networking books focus on explaining the underlying protocol and its intricacies, even going as far as to re-implement TCP on top of another protocol like UDP or raw sockets. This book won't go there.

It will embrace the notion that the Berkeley Sockets API can be used without knowing the underlying protocol implementation. It will focus on how to use the API to do interesting things and will keep as much focus as possible on getting real work done.

However, there are times, when making performance optimizations, for example, when a lack of understanding of the underlying protocol will prevent you from using a feature properly. In these cases I'll yield and explain the necessary bits so that the concepts are understood.

Back to protocols. I've already said that TCP won't be covered in detail. The same is true for application protocols like HTTP, FTP, etc.. We'll look at some of these as examples, but not in detail.

If you're really interested in learning about the protocol itself I'd recommend Stevens' TCP/IP Illustrated http://www.amazon.com/TCP-Illustrated-Vol-Addison-Wesley-Professional/dp/0201633469 .

netcat

There are several places in this book where the netcat tool is used to create arbitrary connections to test the various programs we're writing. netcat (usually nc in your terminal) is a Unix utility for creating arbitrary TCP (and UDP) connections and listens. It's a useful tool to have in your toolbox when working with sockets.

If you're on a Unix system it's likely already installed and you should have no issues with the examples.

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Working With TCP Sockets»

Look at similar books to Working With TCP Sockets. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Working With TCP Sockets»

Discussion, reviews of the book Working With TCP Sockets and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.