Code: int mrim_test() { SOCKET hSock; struct sockaddr_in hAddr; char buf[1024], req[256]; int res; struct _MRIM_ADDR mrim_addr; struct mrim_packet_header_t cs, sc; if((hSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { printf("[-] create socket\n"); return -1; } printf("[+] create socket\n"); hAddr.sin_family = AF_INET; hAddr.sin_port = htons(MRIM_PORT); hAddr.sin_addr.s_addr = inet_addr(MRIM_HOST); // ip mrim.mail.ru if(connect(hSock, (struct sockaddr*)&hAddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { printf("[-] connect 2 mrim.mail.ru:443\n"); closesocket(hSock); return -1; } printf("[+] connect 2 mrim.mail.ru:443\n"); sprintf(req, "CONNECT mrim.mail.ru:443 HTTP/1.0\r\n\r\n"); if(send(hSock, req, strlen(req), 0)==SOCKET_ERROR) { printf("[-] send packet 2 mrim.mail.ru:443\n"); closesocket(hSock); return -1; } printf("[+] send packet 2 mrim.mail.ru:443\n"); if(recv(hSock, buf, sizeof(buf)-1, 0)==SOCKET_ERROR) { printf("[-] recv answer from mrim.mail.ru:443\n"); closesocket(hSock); return -1; } printf("[+] recv answer from mrim.mail.ru:443\n"); strtok(buf, "\r\n"); strtok(buf, ":"); strcpy(mrim_addr.host, buf); mrim_addr.port = atoi(strtok(NULL, ":")); printf("[+] get connection server: %s:%d\n", mrim_addr.host, mrim_addr.port); printf("\nrecreating socket...\n\n"); closesocket(hSock); hSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if((hSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) { printf("[-] create socket\n"); return -1; } printf("[+] create socket\n"); hAddr.sin_family = AF_INET; hAddr.sin_port = htons(mrim_addr.port); hAddr.sin_addr.s_addr = inet_addr(mrim_addr.host); if(connect(hSock, (struct sockaddr*)&hAddr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { printf("[-] connect 2 %s:%d\n", mrim_addr.host, mrim_addr.port); closesocket(hSock); return -1; } printf("[+] connect 2 %s:%d\n", mrim_addr.host, mrim_addr.port); cs.magic = CS_MAGIC; cs.proto = PROTO_VERSION; cs.msg = MRIM_CS_HELLO; if(send(hSock, (unsigned char*)&cs, PACKET_SIZE, 0) == SOCKET_ERROR) { printf("[-] send MRIM_CS_HELLO\n"); closesocket(hSock); return -1; } printf("[+] send MRIM_CS_HELLO\n"); if (recv(hSock, (char *)&sc, PACKET_SIZE, 0) == SOCKET_ERROR) { printf("[-] recv MRIM_CS_HELLO\n"); closesocket(hSock); return -1; } [COLOR=Red][B]printf((sc.msg == MRIM_CS_HELLO_ACK ? "[+] recv MRIM_CS_HELLO_ACK\n": "[+] recv %d\n"), sc.msg);[/B][/COLOR] closesocket(hSock); return 0; } Собственно в выделенном месте серв должен возвращать MRIM_CS_HELLO_ACK на сколько я понимаю, но у меня этого не происходит, скорее всего что-то напутал. Прошу помощи, нужно дойти до авторизации.