- Moved error codes to errno.h

- Removed non-working files for compilation via gcc.

git-svn-id: svn://kolibrios.org@8536 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
superturbocat2001
2021-01-15 21:48:24 +00:00
parent b29cc6670d
commit a61177b2ae
10 changed files with 63 additions and 200 deletions
@@ -35,22 +35,22 @@ int main() {
puts("Connecting...\n");
if (connect(sock, addr_info->ai_addr, addr_info->ai_addrlen) != 0) {
printf("Connection failed, err_code = %d\n", err_code);
exit(err_code);
printf("Connection failed, errno = %d\n", errno);
exit(errno);
}
puts("Connected successfully\n");
puts("Sending request...\n");
if (send(sock, request, strlen(request), MSG_NOFLAG) == -1) {
printf("Sending failed, err_code = %d\n", err_code);
exit(err_code);
printf("Sending failed, errno = %d\n", errno);
exit(errno);
}
puts("Request sended successfully, waiting for response...\n");
char buf[512 + 1];
if (recv(sock, buf, 512, MSG_NOFLAG) == -1) {
printf("Receive failed, err_code = %d\n", err_code);
exit(err_code);
printf("Receive failed, errno = %d\n", errno);
exit(errno);
}
printf("Response = %s\n", buf);
@@ -61,4 +61,4 @@ int main() {
puts("\n goodbye)\n");
con_exit(0);
return 0;
}
}
@@ -11,18 +11,18 @@ int main()
struct sockaddr addr={AF_INET4, PORT(23) , 0, 0};
int sk1=socket(AF_INET4, SOCK_STREAM, IPPROTO_TCP);
printf("Open socket: %d. Error: %d\n",sk1, err_code);
printf("Open socket: %d. Error: %d\n",sk1, errno);
bind(sk1, &addr,sizeof(addr));
printf("Socket binding. Error: %d\n", err_code);
printf("Socket binding. Error: %d\n", errno);
listen(sk1, 1);
printf("Listening to a socket. Error: %d\n", err_code);
printf("Listening to a socket. Error: %d\n", errno);
int sk2 = accept(sk1, &addr, sizeof(addr));
printf("Accept done. Error: %d\n", err_code);
printf("Accept done. Error: %d\n", errno);
send(sk2, msg1, strlen(msg1),MSG_NOFLAG);
printf("Send message: '%s' Error: %d\n", msg1, err_code);
printf("Send message: '%s' Error: %d\n", msg1, errno);
puts("Received data:");
while(msg2!='!')
{