forked from KolibriOS/kolibrios
- 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:
@@ -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!='!')
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user