Entradas

Mostrando entradas de septiembre, 2018

TCP/IP

I found a super cool video that explains how TCP/IP evolved from OSI. It's only 20 minutes and you'll understand much better how the TCP/IP protocol works.


Network Socket

What is a Network Socket?

A network socket is an internal endpoint for sending or receiving data within a node on a computer network (Wikipedia).
-------------------------

You are using sockets when you download a pdf file or when whatsapp connects to its server, you are using network sockets all the time. Network sockets are used to transport information to/from a remote end point. So, you could say from previous posts, what's the difference with HTTP?

HTTP is an application protocol. It basically means that HTTP itself can't be used to transport information to/from a remote end point. ... The socket API supports different protocols from the transport layer and down.

 For example, in a connection between 10.20.30.40:4444 and 50.60.70.80:8888 (local IP address:local port, foreign IP address:foreign port), there will also be an associated socket at each end, corresponding to the internal representation of the connection by the protocol stack on that node, which are referred to locally by numerical socket descriptors, say 317 at one side and 922 at the other. A process on node 10.20.30.40 can request to communicate with node 50.60.70.80 on port 8888 (request that the protocol stack create a socket to communicate with that destination), and once it has created a socket and received a socket descriptor (317), it can communicate via this socket by using the descriptor (317).
 

Protocol stacks, usually provided by the operating system, is a set of programs that allow processes to communicate. The API that programs use to communicate using network sockets is called a socket API.

In TCP and UDP (standard Internet Protocols), a socket adress is the combination of an IP adress and a port number.

Ex: Sending the string "Hello, world!" via TCP to port 80.
Socket socket = getSocket(type = "TCP")
connect(socket, address = "1.2.3.4", port = "80")
send(socket, "Hello, world!")
close(socket)

Learning a Programming Language

Here I'm going to expose what I believe is an optimal way to learn any programming language for beginner-intermediate profiles.

So picture this example:  from school you have some few experience with C++ and you want to become at some point proficient with Java, but you have 0 idea on it. How can you do that?

Some people would take a book about Java and they will do with it. But for the rest of us is not like this. We start with a lot of motivation, but at the end of the day, at chapter 3-4 we quit. WHY? Because who wants to spend the day reading a goddamn book about Java, you want to develop apps or games! So maybe you need something more practical.

1.- CodeCamp (https://www.freecodecamp.org/). It's a platform where you can learn the basics of several programming languages. So you go here and you learn in a practical way about Java.

2.- After one whole afternoon in CodeCamp you should move to CodeWars ( https://www.codewars.com/). Codewars is another platform full of practical programming exercises. Exercises are divided in katas from 8 to 1 (being 8 the easier level). Here is where you are going to start programming. Once you finish an exercise you will see other people solutions. Codewars is one of the best tool you can find, believe me. Very important this webpage (https://stackoverflow.com/), Stackoverflow is the bible of any programmer, it does not matter how dumb is your question, you are going to find an answer there.

 

3.- You need some weeks for reaching a 4-3 kyu level. At this point you have a nice insight in the programming language, although I'm sure you have several flows in many points. You should continue practicing and NOW you get a goddamn book, you learn good practices, and you understand from simple to more difficult characteristics of the language.

4.- At this point you need some real practice, you need to build something, so your platflorm is GitHub (https://github.com/), go there and register, find a nice project that suits you and practice a lot!