When I was a freshman, I started to do network programming in C language, you know socket, bind, listen, ACCPET, RECv, send and all that stuff.

I hold a book borrowed from the library, according to the above tips, line by line according to the computer, successfully write a TCP server and client, can be used to send and receive messages.

But both the client and the control are running on my own computer, so it’s boring to send messages to myself. So I sent the client to my roommate, and he and I could communicate across computers.

So on the dark console window, we talked, although he was opposite me, although it was just a text message, although so simple, my roommate still praised me good, let me full of sense of achievement, network programming is so interesting.

After the successful operation, I teamed up with my roommates to play a few pieces of crossfire, happy ~

The picture

The next day, I began to think of sending the client to my girlfriend who was 2 kilometers away, so that we could use it to chat in our dormitories at night instead of QQ. It was quite romantic

The picture

I didn’t expect to be scorned immediately, just this black thing? Can’t you just make a nice interface?

Yeah, it’s really hard to see, at least like QQ, it has a chat interface, it has a send button, and it would be nice if it could send pictures.

So I did for a week, with **VC++** to get a simple interface, but also from the Internet to make a beautiful skin plus, this is much more beautiful.

I excitedly sent the program to my girlfriend, expecting her adoring glances.

But the goose…

She incredibly told me on QQ: played a window, hint can not connect the server!

The picture

I left the server open, didn’t I? But there’s no connection.

I quickly calm down, the teacher taught, can use the ping command to see if the network connectivity.

I used QQ to remotely operate the desktop and pinged my computer on her computer:

Ping 192.168.1.103

Wow!!! Ping is not working!

I weakly weakly consulted the elder brother that has experience, then was despised again: you this ability ping pass strange, this is LAN address!

I was confused. What is a LAN address? Why can’t I get through?

At that time, I just learned C language, computer network courses just contact, with small white to describe completely.

So I began to charge crazily, and then I knew what public address is, what is private address, and I knew that the router in the dormitory has a function called NAT, which will secretly change the private ADDRESS of the LAN to the public address of our computer. Once out of the dormitory, it is to communicate with the public address.

NAT alleviates the problem of insufficient IP addresses, allowing several of us to share the same IP address in the dormitory to access the Internet.

Now it seems very simple technology, but at that time did not know is not know ah, so make a joke.

So I found the public IP address of the WLAN port on the router, replaced the server address in the client code, recompiled a package and sent it to my girlfriend.

Is that all right now?

But goose, still no good!

Estimate everybody see here, in the mind also say that sentence: so if can line strange!

Yes, it’s a public address, but there’s no router configured to forward it.

It took me a while to learn something called UPnP, which is to configure port forwarding on the router, mapping the port number from the public IP address to a port at a certain address in the LAN, so that when the router with the public IP address receives the connection, it forwards it to the server on my computer.

I login to the router background, my server to monitor the port number to do the mapping configuration, can not wait to let my girlfriend try again!

Finally, this time she told me: connected!

Finally, I sent her the first message: Hello, World!

Good mood, and a meat dish at noon ~

Setting up a connection using an IP address is not always a good idea, because the public IP address on the router often changes, and each time it changes, a client needs to be recompiled, which can be troublesome.

Otherwise manual input every time, but I can’t leave an input box for my girlfriend to fill in the IP address every time, she will certainly question me: why I login QQ, they didn’t let me fill in QQ IP address ah?

So I did some searching and learned that domain names can be used instead of IP to solve this problem.

The program code replaces the IP with a domain name, which is then dynamically resolved to an IP address. The IP address of the server is no longer written into the code.

But then the question is, do you have to register a domain name for something like this? Do I have to charge for domain name registration?

Public IP addresses often change, is it necessary to change the domain name mapping IP address, this is also troublesome ah!

And double 叒 after a while of research, and learned a thing called DDNS dynamic domain name resolution, a software called peanut shell, download a client, my several problems are arranged clearly.

You do not need to register a domain name, with the peanut shell below the subdomain name on the line, with the client, you can change the IP address of the domain name mapping at any time, convenient and fast.

I changed my program again and finally solved the problem.

However, the new problem soon came, I can only server and client communication, if a third person, a fourth person to join, how to do?

Continue to change!

Back to the main topic of today’s writing.

People often ask me on wechat: Xuan Yuan, how should XXX learn ah? I’m white. Do you have a chance?

In fact, who is not from the small white came over, who has not been despised on the way of learning, have not made jokes? The so-called hearing tao has successively, the technique profession has specialized, and so on.

From my own learning experience summary, if you want to learn solid technology, just look at courses and books is far from enough, you have to start!

Get your hands on some projects, and when you have a real problem, you know what the various technologies mean and what the problem is, and it’s much better than reading a book or a blog.

After several years of work, I found that the most rapid accumulation of basic knowledge or college years. After work, I don’t have many opportunities to deal with basic courses such as operating system, computer network, data structure and algorithm in daily work. I spend more time writing API interfaces, doing CRUD, and building blocks of framework code. Or learn how to use third-party components such as Redis, mysql, RabbitMQ, elasticSearch, etc.

During my college years, I have roughly done the following projects:

Instant messaging software

Static Web server

Remote desktop control software

Network traffic recovery software

Windows kernel ARK tool

Although it seems every do quite rough, from practical there are a lot of distance, but the basic function is completed, and by developing these things, not only for the time of the I have a lot of programming ability to ascend, and in the process, constantly find new technical term, stress, also learned a lot that no textbook.

The best time to plant a tree was ten years ago. The second best time is now. ** For those who are learning programming, if you want to improve your core programming ability (internal work), you can become a promising talent in the future! ** I may be able to help you here ~

C language C++ programming learning exchange circle, [click to enter] wechat official account: C language programming learning base

Organize and share (years of learning source code, project actual combat video, project notes, basic introduction tutorial)

Welcome to change careers and learn programming partners, use more information to learn and grow faster than their own thinking oh!

Programming learning books:

Programming learning video sharing: