aboutsummaryrefslogtreecommitdiff
path: root/tests/websockets_bi_side.c
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-10-03 17:38:19 -0700
committerAlon Zakai <alonzakai@gmail.com>2012-10-03 17:38:19 -0700
commit4f2f867026315a33a30344a9cedc500568e9cb04 (patch)
tree2ce5753fd55eb8f7d310d3f4c9692accaa3004b7 /tests/websockets_bi_side.c
parent363ce16a8980f08b9c81fea4d51d3356cbad21a9 (diff)
socket listen faking
Diffstat (limited to 'tests/websockets_bi_side.c')
-rw-r--r--tests/websockets_bi_side.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/websockets_bi_side.c b/tests/websockets_bi_side.c
index ab9fa86a..c9c50618 100644
--- a/tests/websockets_bi_side.c
+++ b/tests/websockets_bi_side.c
@@ -7,15 +7,15 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sys/ioctl.h>
+#if EMSCRIPTEN
#include <emscripten.h>
+#endif
#define EXPECTED_BYTES 5
int main(void)
{
-emscripten_run_script("console.log('hallo from siide')");
- printf("hello from side page\n");
-
struct sockaddr_in stSockAddr;
int Res;
int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -29,7 +29,7 @@ emscripten_run_script("console.log('hallo from siide')");
memset(&stSockAddr, 0, sizeof(stSockAddr));
stSockAddr.sin_family = AF_INET;
- stSockAddr.sin_port = htons(8995);
+ stSockAddr.sin_port = htons(SOCKK);
Res = inet_pton(AF_INET, "127.0.0.1", &stSockAddr.sin_addr);
if (0 > Res) {
@@ -42,15 +42,24 @@ emscripten_run_script("console.log('hallo from siide')");
exit(EXIT_FAILURE);
}
+ printf("connect..\n");
+
if (-1 == connect(SocketFD, (struct sockaddr *)&stSockAddr, sizeof(stSockAddr))) {
perror("connect failed");
close(SocketFD);
exit(EXIT_FAILURE);
}
+ printf("send..\n");
+
char data[] = "hello from the other siide\n";
send(SocketFD, data, sizeof(data), 0);
+ printf("stall..\n");
+
+ //int bytes;
+ //while (1) ioctl(SocketFD, FIONREAD, &bytes);
+
return EXIT_SUCCESS;
}