Sockets in Python for beginners. PC sockets What is it Motherboard socket

Sockets in Python for beginners.  PC sockets What is it Motherboard socket

As part of this review, I will tell you what a socket is, as well as some features.

Previously, computers were solid, the necessary microcircuits were soldered directly to the main board. Therefore, improvement at home was either extremely difficult or impossible. Nowadays, a computer requires the replacement of individual parts. For example, you can install a more powerful processor, video card, add RAM, and so on.

This became possible due to the fact that special connectors were added to the motherboard, one of which is a socket.

But first things first.

A socket is

Socket- This is a connector for connecting the processor to the motherboard. To give a life analogy, it’s like a wire plug and a socket in the wall.

Note: It is worth knowing that this term is also used in programming. There, in a general sense, a socket means a software interface for data exchange.

As already mentioned, the main task of the socket is to provide the ability to easily replace parts or improve the performance of the computer. For example, if you need a more powerful processor, you don't need to change your computer completely. This approach significantly saves money and also extends the life of computers.

How are sockets different?

The most important thing that every user needs to know is that the sockets of the processor and motherboard must be the same, otherwise, at best, the computer will not start, and at worst, one of them will have to be changed. Basically, it’s like in life: pushing a USB cable into a network card port is not the best idea. But it’s still worth remembering this.

However, there are backwards compatible socket extensions, but they are very few. For example, a motherboard that supports socket AM3+ may allow you to connect processors with socket AM3 (you need to check the motherboard specification).

Physical differences between sockets:

1. The size itself. Width and height.

2. Number of contacts. Nowadays it is measured in hundreds and reaches 1000+. For example, socket AM4 has 1331 pins (AMD processors), while LGA 2011 or Socket R (Intel server processors) has 2011 pins.

3. Type of contacts. Either with or without contact feet.

4. Cooler mounting distance. It would seem what a difference there could be in a cooling device. However, it exists due to the difference in width and length. Therefore, if you need a more powerful CPU cooler rather than a standard one, then you need to consider the socket.

Note: In principle, you can attach a cooler from another socket (their main task is heat removal), but it’s better not to do this.

Technological differences of sockets:

1. Power and performance. For example, old sockets, even if current processors are connected to them using a file, simply will not be able to handle such power.

2. Supported RAM. We are talking about the DDR type, supported frequencies and volume.

3. Various additional features. For example, does the socket support the possibility of an integrated video card in the processor.

Main socket lines

If we talk about common household appliances, including computers, the main lines of sockets are Intel and AMD. However, it is worth knowing that specialized devices, for example, powerful servers, can be equipped with other processor lines (Oracle, IBM, NVidia, and so on). It just so happened historically that at the current time there are 2 lines.

Each of the lines implies division into specific sockets. Each individual socket typically supports a small set of processors. For example, AM3+ supports AMD processors FX-4100, FX-4300, FX-6100, FX-6300 and so on up to FX-9000. Socket H2 (LGA 1155) from Intel supports processors with Intel Sandy Bridge and Intel Ivy Bridge architecture (for example, Core i3/i5/i7 of certain models).

If we talk about qualities, the AMD line is considered more budget-friendly and its processors are better for overclocking, but the Intel line of processors consumes less watts, is more stable and productive. Although, as they say, as many people as there are so many opinions.

I also advise you to read the review.

What is a socket?

You constantly hear talk about some kind of “sockets” and you are probably wondering what they are. In general, sockets are originally a way for programs to communicate with each other using Unix file descriptors.

OK -- you've probably heard some Unix hacker say something like, "Oh my God, everything in Unix is ​​files!" This person may have meant that Unix programs read or write to a file descriptor for absolutely any I/O. A file handle is a simple integer associated by the operating system with an open file. But (and this is the trap) the file can be a network connection, a FIFO, pipes, a terminal, a real file on disk, or just anything else. Everything in UNIX is a file! So, just trust that if you are going to communicate with another program over the Internet, you will have to do it through a file descriptor.

"Hey, smart guy, where do I get this file descriptor to use on the network?" I will answer.
You are making a socket() system call. It returns a socket handle and you communicate through it using the send() and recv() system calls (man send, man recv).

"But, hey!" you might exclaim. "If it's a file descriptor, why can't I use simple read() and write() functions to communicate through it?" The answer is simple: “You can!” A slightly longer answer: "You can, but send() and recv() offer much more control over the transmission of your data."

What's next? How about this: There are different types of sockets. There are DARPA Internet addresses (Internet Sockets), CCITT X.25 addresses (X.25 sockets that you don't need), and probably many others depending on the specifics of your OS. This document describes only the first, Internet Sockets.

Two types of Internet sockets

What? Are there two types of internet sockets? Yes. Okay, no, I'm lying. There is more, but I don't want to scare you. There are also raw sockets, a very powerful thing, you should take a look at them.

OK. What are the two types? One of them is a “stream socket”, the second is a “datagram socket”, henceforth they will be called “SOCK_STREAM” and “SOCK_DGRAM”, respectively. Datagram sockets are sometimes called "connectionless sockets" (although they can also connect() if you really want to. See connect() below.)

Stream sockets provide reliability with their two-way communication system. If you send two elements to the socket in the order “1, 2”, they will arrive to the “interlocutor” in the same order - “1, 2”. In addition, error protection is provided.

What uses stream sockets? Well, you've probably heard about the Telnet program, right? Telnet uses a stream socket. All the characters you type should arrive on the other end in the same order, right? Additionally, browsers use the HTTP protocol, which in turn uses stream sockets to fetch pages. If you telnet to any website on port 80 and type something like "GET / HTTP/1.0" and press enter twice, a bunch of HTML will fall on you ;)

How do stream sockets achieve high levels of data transfer quality? They use a protocol called "The Transmission Control Protocol", otherwise known as "TCP". TCP ensures that your data is transmitted consistently and without errors. You may have previously heard of TCP as half of "TCP/IP", where IP stands for "Internet Protocol". IP deals primarily with Internet routing and is not itself responsible for data integrity.

Cool. What about datagram sockets? Why are they called connectorless? What's the matter? Why are they unreliable?
Well, here are some facts: if you send a datagram, it can get through. Or maybe it won't come. But if it does arrive, then the data inside the package will be without errors.

Datagram sockets also use IP for routing, but do not use TCP; they use "User Datagram Protocol", or "UDP".

Why doesn't UDP establish connections? Because you don't need to keep an open connection with stream sockets. You simply construct a packet, form an IP header with recipient information, and send the packet out. There is no need to establish a connection. UDP is typically used either where the TCP stack is unavailable, or where one or two missed packets does not lead to the end of the world. Application examples: TFTP (trivial file transfer protocol, little brother of FTP), dhcpcd (DHCP client), network games, audio streaming, video conferencing, etc.

"Wait a minute! TFTP and DHCPcd are used to transfer binary data from one host to another! Data cannot be lost if you want to work with it properly! What kind of dark magic is this?"

Well, my human friend, TFTP and similar programs usually build their own protocol on top of UDP. For example, the TFTP protocol states that for every packet received, the recipient must send back a packet saying "I got it!" ("ACK" packet). If the sender of the original packet does not receive a response within, say, 5 seconds, it will resend the packet until it finally receives an ACK. Such procedures are very important for implementing reliable applications that use SOCK_DGRAM.

For applications that don't require such reliability - games, audio or video - you simply ignore the lost packets or perhaps try to compensate for them somehow. (Quake players usually call this phenomenon "damned lag", and "damned" is an extremely mild term).

Why would you want to use an untrusted underlying protocol? For two reasons: speed and speed. This method is much faster, fire-and-forget, than constantly monitoring whether everything has arrived safely at the recipient. If you're sending a chat message, TCP is great, but if you're sending 40 character positional updates per second, it might not be that important if one or two of them get lost, and UDP is a good choice.

Network theory and low levels

Since I just mentioned protocol layers, it's time to talk about how the network actually works and show examples of how SOCK_DGRAM packets are constructed. You can actually skip this section, but it is a good theoretical reference.

Hey kids, it's time to talk about data encapsulation! This is a very, very important thing. This is so important that you should learn it by heart.
Basically the gist is this: the package is born; the packet is wrapped (“encapsulated”) in a header by the first protocol (say, TFTP), then the whole thing (including the TFTP header) is encapsulated again by the next protocol (say, UDP), then again by the next one (say, IP), and finally by the final one, physical protocol (say, Ethernet).

When another computer receives the packet, the hardware (network card) strips the Ethernet header (unfolds the packet), the OS kernel strips the IP and UDP headers, the TFTP program strips the TFTP header, and finally we get the bare data.

Now we can finally talk about the infamous OSI model - the layered network model. This model describes a network functionality system that has many advantages over other models. For example, you can write in your program as sockets that send data without worrying about how the data is physically transmitted (serial port, Ethernet, modem, etc.), since programs at lower levels (OS, drivers) do do all the work for you, and present it transparently to the programmer.

Actually, here are all the levels of the full-scale model:


  • Applied

  • Executive

  • Session

  • Transport

  • Network

  • Duct

  • Hardware (physical)

The physical layer is the hardware; com port, network card, modem, etc. The application layer is the furthest away from the physical layer. This is where the user interacts with the network.

For us, this model is too general and extensive. A network model we can use might look like this:


  • Application layer (Telnet, FTP, etc.)

  • Host-to-host transport protocol (TCP, UDP)

  • Internet Layer (IP and Routing)

  • Network access level (Ethernet, Wi-Fi or whatever)

Now you can clearly see how these layers correspond to the encapsulation of the original data.

See how much work it is to create one simple package? Wow! And you must type all these packet headers yourself in notepad! Kidding. All you have to do with stream sockets is send() the data out. The OS kernel will build TCP and IP headers, and the hardware will take over the network access layer. Ah, I love modern technology.

This concludes our brief excursion into network theory. Oh yes, I forgot to tell you: everything I wanted to tell you about routing: nothing! Yes, yes, I won't say anything about it. The OS and IP protocol will take care of the routing table for you. If you are really interested, read the documentation on the Internet, there is a lot of it.

The motherboard is an important component of the computer, which provides communication between all elements of the system. Model information will be useful when replacing the processor. There are several ways to find out the motherboard socket.

What is a motherboard socket

A socket is an interface for connecting the processor to the system. The motherboard is the platform to which all other devices are connected:

  • RAM;
  • video card;
  • hard disks.

The socket allows for the correct installation of the processor, which is not universal and cannot fit the boards of all devices. Therefore, if there is a need to change the processor, you need to familiarize yourself with the corresponding characteristics of the motherboard.


The socket allows you to install the processor correctly

All sockets can be divided into two types:

  1. Intel.

They differ:

  • number of contacts (400, 500, 1000 and even more);
  • type of contacts;
  • distance for mounting coolers;
  • socket size;
  • the presence or absence of additional controllers;
  • the presence or absence of support for graphics integrated into the processor;
  • performance parameters.

Intel and AMD sockets differ not only in the number and type of pins, but also in performance parameters, as well as the presence of additional controllers

Determination methods

Documentation

When purchasing a computer or laptop, it comes with documentation that describes all the characteristics, including the parameters of the motherboard. The socket number looks like “Socket...” or the shorter version “S...”. In this section you can also find recommendations for installing processors suitable for this system.

Pay

Very often, motherboard manufacturers write the name of the socket next to the place where the processor is mounted. To obtain information in this way, you will have to put in a little more effort, partially disassembling the computer.


Manufacturer

Computer manufacturers are required to disclose absolutely all characteristics of the device when selling. This information is open and can be easily found on the Internet.

  1. In any available search engine (Google, Yandex, Yahoo, Mail), enter the name of the computer manufacturer.
  2. Go to the manufacturer or retailer's website.
  3. Find your model in the product catalog. The socket will be indicated in its characteristics.

CPU

The socket can also be recognized by the processor model, which is indicated in the settings of the computer’s operating system.

For example, in Windows, the processor model can be found in the following path: Control Panel / System.

You can compare processor and socket models using the table.

Manufacturer Intel
Socket CPU
Socket 370 Pentium III
Socket 423 Pentium, celeron 4
Socket 478 Pentium, celeron 4
LGA 775

Pentium D, Celeron D, Pentium EE, Core 2 Duo, Core 2 Extreme, Celeron,

Xeon 3000 series, Core 2 Quad

LGA 1156

Core i7,Core i5,Core i3

LGA 1366 Core i7
Manufacturer AMD
Socket CPU
Socket A (Socket 462) Athlon, Athlon XP, Sempron, Duron
Socket 563 Athlon XP-M
Socket 754 Athlon 64
Socket 939 Athlon 64 and Athlon 64 FX

Processor specifications can be found on the manufacturer's or seller's website

Software

Everest is a program that scans the system and shows the user all its characteristics. In appearance it resembles a conductor. On the left there is a column with windows of information blocks; when you click on them, the required information is displayed on the right. To find out the socket, you need to go through the following path: Computer / DMI / Processors / Your processor / Connector type.


Everest scans the system and shows all its characteristics

CPU-Z

This program has a simple interface. When you open it, you can see all the characteristics of the processor in the first tab. The Package item describes the parameters of the motherboard socket.


The CPU-Z program has a simple interface. Information about the motherboard socket can be found in the Package tab

Everything you need to know about sockets (video)

Knowing the socket model is necessary when replacing a processor. You can find out information in several ways: using documentation, the board itself, the Internet or software.

Back in 2010, I wrote an article for beginners about sockets in Python. Now this blog has sunk into oblivion, but I found the article quite useful. I found the article on a flash drive in a Libr document, so this is not a cross-post, not a copy-paste - it is nowhere to be found on the Internet.

What is this

First we need to understand what sockets are and why we need them. As the wiki says, a socket is a software interface for facilitating information exchange between processes. But it is much more important not to memorize the definition, but to understand the essence. Therefore, I will try to tell everything here in as much detail and as simply as possible.

There are client and server sockets. It's quite easy to guess what's what. The server socket listens on a specific port, and the client socket connects to the server. Once the connection has been established, data exchange begins.


Let's look at this with a simple example. Let's imagine a large hall with many small windows behind which girls stand. There are also empty windows with no one behind them. Those same windows are ports. Where the girl stands is an open port, behind which there is some application that listens to it. That is, if you approach the window with number 9090, they will greet you and ask how they can help. It's the same with sockets. An application is created that listens on its port. When a client establishes a connection to a server on this port, it is this application that will be responsible for working with this client. You won’t go up to one window and they’ll shout at you from the next one :)

After a successful connection is established, the server and client begin to exchange information. For example, the server sends a greeting and prompts you to enter a command. The client, in turn, enters a command, the server analyzes it, performs the necessary operations and returns the result to the client.

Server

Now create two files - one for the server and the other for the client.

Python uses the socket module to work with sockets:

Import socket

First of all, we need to create a socket:

Sock = socket.socket()

There is nothing special here and this part is common for both client and server sockets. Next we will write code for the server. This is quite logical - why should we write a client application if there is nowhere to connect :)

Now we need to decide on the host and port for our server. As for the host, we will leave the line empty so that our server is accessible to all interfaces. Let's take any port from zero to 65535. It should be noted that in most operating systems, listening to ports numbered 0 - 1023 requires special privileges. I chose port 9090. Now let's bind our socket to the given host and port using the bind method, which is passed a tuple, the first element (or zero, if counting from zero) of which is the host, and the second is the port:

Sock.bind(("", 9090))

Now we are ready to accept connections. Using the listen method, we will start listening mode for this socket. The method takes one argument - the maximum number of connections in the queue. Let's strain our wild imagination and remember about the hall with windows. So this parameter determines the size of the queue. If it is set to one, and someone, clearly superfluous, is trying to adjust from behind, then they will send him :) Let’s set it to one:

Sock.listen(1)

Well, finally, we can accept the connection using the accept method, which returns a tuple with two elements: the new socket and the client address. It is this socket that will be used to receive and send data to the client.

Conn, addr = sock.accept()

That's all. Now we have established a connection with the client and can “communicate” with him. Because Since we cannot know exactly what and in what volumes the client will send us, we will receive data from him in small portions. To receive data, you need to use the recv method, which takes the number of bytes to read as an argument. We will read in chunks of 1024 bytes (or 1 kB):

While True: data = conn.recv(1024) if not data: break conn.send(data.upper())

As we said, to communicate with the client we use the socket that we received as a result of executing the accept method. We are in an infinite loop receiving 1024 bytes of data using the recv method. If there is no more data, this method returns nothing. This way we can receive any amount of data from the client.

Now you can close the connection:

The server itself is ready. It accepts a connection, takes data from the client, returns it as an uppercase string, and closes the connection. It's simple :) In the end you should have the following:

#!/usr/bin/env python # -*- coding: utf-8 -*- import socket sock = socket.socket() sock.bind(("", 9090)) sock.listen(1) conn, addr = sock.accept() print "connected:", addr while True: data = conn.recv(1024) if not data: break conn.send(data.upper()) conn.close()

Client

I think it will be easier now. And the client application itself is simpler - we need to create a socket, connect to the server, send it data, receive data and close the connection. All this is done like this:

#!/usr/bin/env python # -*- coding: utf-8 -*- import socket sock = socket.socket() sock.connect(("localhost", 9090)) sock.send("hello, world !") data = sock.recv(1024) sock.close() print data

I think everything is clear, because... everything has already been sorted out before. The only new thing here is the connect method, with which we connect to the server. Next we read 1024 bytes of data and close the socket.

During the upgrade process or when configuring a new system unit, one of the main factors for its successful assembly is the correctly selected and compatible components. To achieve this, manufacturers have introduced certain standards for the compatibility of these same components.

For example, when replacing a central processor, there is a different designation (CPU), it is very important to understand exactly what type of socket it has and whether it will fit the connector on the motherboard of a personal computer.

What it is

The main and very important parameter of the motherboard is the central processor socket (CPU socket). This is a socket located on the main board of the computer, intended for installing a CPU into it. And before connecting these components into one coherent system, you need to determine whether they are compatible with each other or not. It's like plugging a plug into a socket., if the plug is American standard and the socket is European, then naturally they will not fit together and the device will not work.

As a rule, in retail outlets selling computer components, in the price tag on the window or in the price list, the main parameters of the processor that is being sold are always indicated. Among these parameters, the type of socket to which this processor is suitable is indicated. The main thing when buying is to take into account this primary characteristic of the CPU.

This is important because when installing the processor into the motherboard socket, if you choose the wrong socket, it simply will not fit into its place. In the huge selection of connectors that exists today, there are two main types:

  • Sockets for central processors from the manufacturer AMD.
  • Sockets designed for processors manufactured by Intel.

Intel and AMD socket specifications

  • Physical dimensions of socket.
  • The method of connecting the contacts of the socket and the processor.
  • Type of mounting of the CPU cooler cooling system.
  • The number of sockets or contact pads.

Connection method - there is nothing complicated here. The socket has either sockets (like AMD) into which the processor contacts are inserted. Either pins(like Intel), on which the flat contact pads of the CPU rest. There is no third option here.

The number of sockets or pins - there are many options here, their number can range from 400 to 2000, and maybe even more. You can determine this parameter by looking at the marking of the socket in the name of which this information is encoded. For example, the Intel Core i7-2600 for the Intel LGA 1155 processor socket has exactly 1155 contact pads on its surface. The abbreviation LGA means that the processor has flat contacts, and the socket, on the contrary, consists of 1155 pins.

Well, the mounting methods for the CPU cooling system may differ: in the distance between the holes on the motherboard designed to secure the lower part of the cooling system. And the method of fixing the upper half, consisting of a radiator and cooler. There are also exotic cooling options made at home, or systems with a water method of lowering the CPU temperature.

There are other characteristics that are directly related to the functionality of the entire motherboard and its performance. The presence of a socket of a certain standard also indicates what possible parameters are included in this platform and how modern this motherboard is. Here are some features that distinguish a board built on a specific socket and a chipset developed for it:

  • Processor clock speed range, number of supported cores and data transfer speed.
  • The presence of controllers on the motherboard that expand the functionality of the board.
  • Support or presence of a built-in graphics adapter in the motherboard or main processor.

How to determine the socket of a processor

The main component that performs the main task in the operation of a computer is the CPU. And if it fails, then there is nothing left to do but replace it with an analogue similar in connector and characteristics . This is where the challenge arises by determining the socket type. There are many options to find out, and here are three main and available ones.

By manufacturer and model

An easy method using access to the World Wide Web (i.e., via the Internet). All the necessary data on products produced by a particular motherboard manufacturing company is available on the manufacturers’ official websites. The information is not hidden anywhere and can be studied by anyone. You just have to enter the data you need for this into the search bar.

Here is an approximate sequence of actions:

Via Speccy

  1. Download and install the Aida64 or Speccy application on your computer. Next, let's consider the second option. Open the Speccy program. And find in it the section with CPU parameters, it should be called “Central Processor”.
  2. Next, in the selected section, find the line called “Constructive” and read its contents. This is where the type of processor socket will be indicated.
  3. Approximately the same steps will need to be performed when using the Aida64 program. Section “Computer”, subsection DMI, then in the subsection “Processor”, look for a line with the word Socket.

In the documentation

This method is the easiest, but requires documentation attached to the system unit upon purchase. Among the many instructions for the motherboard, processor, video adapter and other components from which the computer is assembled, those intended for the CPU and motherboard are suitable. Carefully scroll through the entire manual and look in it for the words: connector, socket type. This is where information about the socket standard of the motherboard or processor should be.

A personal computer is not a cheap thing, and in some versions it can even cost as much as an old used car. And change it very often- it's a pretty unprofitable business. Even reputable and successful companies do this relatively rarely. But, despite this, from time to time you still have to upgrade and speed up the computing capabilities of any computer.

To do this, you have to disassemble the old hardware and find out information about certain characteristics and parameters. However, you need to take into account your abilities for such procedures. Here, as people say: “If you can’t, don’t bother.” And if there is uncertainty about the success of such an event, then it is better to contact special service centers or individual experienced craftsmen.



top