Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8535 → Rev 8536

/programs/develop/ktcc/trunk/samples/net/http_tcp_demo.c
35,22 → 35,22
 
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);
/programs/develop/ktcc/trunk/samples/net/tcpsrv_demo.c
11,18 → 11,18
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!='!')
{