aboutsummaryrefslogtreecommitdiff
path: root/tests/websockets_bi.c
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2012-11-02 10:22:27 -0500
committerJoel Martin <github@martintribe.org>2013-01-08 17:36:36 -0600
commit6297b4173cd0481b71df333215d03c60c2e1e85b (patch)
treea17ea5e774ca2d044e6d2e77b2cec18d002df126 /tests/websockets_bi.c
parent4379d19dc217376bb11e9c4172c84ac194409c3c (diff)
Support read/write on socket file descriptors.
Add test_websockets_bi_fileops to test using read and write instead of recv and send respectively. Uses same source files with USE_FILE_OPS define.
Diffstat (limited to 'tests/websockets_bi.c')
-rw-r--r--tests/websockets_bi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tests/websockets_bi.c b/tests/websockets_bi.c
index c2dbb7da..24b84d49 100644
--- a/tests/websockets_bi.c
+++ b/tests/websockets_bi.c
@@ -14,6 +14,10 @@
#define EXPECTED_BYTES 28
+#ifndef SOCKK
+#define SOCKK 8992
+#endif
+
int SocketFD;
unsigned int get_all_buf(int sock, char* output, unsigned int maxsize)
@@ -25,7 +29,11 @@ unsigned int get_all_buf(int sock, char* output, unsigned int maxsize)
char buffer[1024];
int n;
unsigned int offset = 0;
+#if TEST_FILE_OPS
+ while((errno = 0, (n = read(sock, buffer, sizeof(buffer)))>0) ||
+#else
while((errno = 0, (n = recv(sock, buffer, sizeof(buffer), 0))>0) ||
+#endif
errno == EINTR) {
if(n>0)
{
@@ -96,13 +104,7 @@ int main(void)
memset(&stSockAddr, 0, sizeof(stSockAddr));
stSockAddr.sin_family = AF_INET;
- stSockAddr.sin_port = htons(
-#if EMSCRIPTEN
- 8993
-#else
- 8992
-#endif
- );
+ stSockAddr.sin_port = htons(SOCKK);
Res = inet_pton(AF_INET, "127.0.0.1", &stSockAddr.sin_addr);
if (0 > Res) {