Junior — Middle
Do you have practical experience working with network protocols and infrastructure?
sobes.tech AI
Answer from AI
Yes, practical experience with network protocols and infrastructure includes understanding and using protocols such as TCP/IP, UDP, HTTP, as well as configuring and debugging network connections.
For example, in C/C++, sockets can be used to create client-server applications:
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <cstring>
#include <iostream>
int main() {
int sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0) {
std::cerr << "Socket creation error" << std::endl;
return 1;
}
sockaddr_in server_addr{};
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(80); // HTTP port
inet_pton(AF_INET, "93.184.216.34", &server_addr.sin_addr); // example.com
if (connect(sock, (sockaddr*)&server_addr, sizeof(server_addr)) < 0) {
std::cerr << "Connection error" << std::endl;
close(sock);
return 1;
}
const char* http_request = "GET / HTTP/1.1\r\nHost: example.com\r\n\r\n";
send(sock, http_request, strlen(http_request), 0);
char buffer[1024];
int bytes_received = recv(sock, buffer, sizeof(buffer) - 1, 0);
if (bytes_received > 0) {
buffer[bytes_received] = '\0';
std::cout << buffer << std::endl;
}
close(sock);
return 0;
}
This experience helps understand how data is transmitted over the network, how connections are established, and how errors are handled.