3
#include <sys/socket.h>
4
#include <netinet/in.h>
10
#include <sys/ioctl.h>
12
#include <emscripten.h>
15
#define EXPECTED_BYTES 5
19
struct sockaddr_in stSockAddr;
22
int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
24
int SocketFD = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
29
perror("cannot create socket");
33
memset(&stSockAddr, 0, sizeof(stSockAddr));
35
stSockAddr.sin_family = AF_INET;
36
stSockAddr.sin_port = htons(SOCKK);
37
Res = inet_pton(AF_INET, "127.0.0.1", &stSockAddr.sin_addr);
40
perror("error: first parameter is not a valid address family");
43
} else if (0 == Res) {
44
perror("char string (second parameter does not contain valid ipaddress)");
49
printf("connect..\n");
51
if (-1 == connect(SocketFD, (struct sockaddr *)&stSockAddr, sizeof(stSockAddr))) {
52
perror("connect failed");
59
char data[] = "hello from the other siide\n";
60
send(SocketFD, data, sizeof(data), 0);
65
//while (1) ioctl(SocketFD, FIONREAD, &bytes);