Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <errno.h>
- #include <iostream>
- #include <unistd.h>
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- /*Сервер должен быть запущен в 1-ой консоли */
- #define PORT 6969
- using namespace std;
- int sock;
- struct sockaddr_in addr;
- int buf[2];
- pthread_mutex_t m1, m2,m3;
- int main() {
- while (1) {
- pthread_mutex_init(&m1, PTHREAD_MUTEX_NORMAL);
- pthread_mutex_init(&m2, PTHREAD_MUTEX_NORMAL);
- pthread_mutex_init(&m3, PTHREAD_MUTEX_NORMAL);
- sock = socket(AF_INET, SOCK_DGRAM, 0);
- addr.sin_family = AF_INET;
- addr.sin_port = htons(PORT);
- addr.sin_addr.s_addr = htonl(INADDR_ANY);
- bind(sock, (struct sockaddr *) &addr, sizeof(addr));
- cout << "Первый катет" << endl;
- cin >> buf[0];
- cout << "Второй катет" << endl;
- cin >> buf[1];
- send(sock, buf, 2, MSG_OOB);
- recv(sock, buf, 2, MSG_OOB);
- //
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement