Commit Graph

209 Commits

Author SHA1 Message Date
Benjamin Sergeant
e251c81d43 fix indentation of greatestCommonDivisor 2019-04-25 16:21:36 -07:00
Benjamin Sergeant
f30a5074ab Remove commented code 2019-04-25 16:16:52 -07:00
Benjamin Sergeant
f6ae490723 Fix data race in WebSocket where _url is accessed without protection in setThreadName
Also fix with url usage + docker container uses fedora and works with tsan
2019-04-25 16:11:46 -07:00
Benjamin Sergeant
a443bbdf80 Fix data races in DNSLookup (tsan) 2019-04-24 21:53:31 -07:00
Benjamin Sergeant
26ee46b246 better server termination / another try at preventing thread join failures 2019-04-24 09:45:53 -07:00
Kumamon38
28210ee31d add boolean and add missing protocol error close constant (#41) 2019-04-23 04:31:55 -07:00
Benjamin Sergeant
323684efff (server) attempt to fix broken macOS unittest on travis CI 2019-04-22 09:36:16 -07:00
Benjamin Sergeant
7df7453365 indentation / comestic changes 2019-04-19 16:57:38 -07:00
Benjamin Sergeant
662f66e501 (socket server) wait for all connections threads to be terminated before exiting stop method 2019-04-19 16:31:33 -07:00
Benjamin Sergeant
cce759b8dd fix Linux cast warning 2019-04-19 15:03:49 -07:00
Benjamin Sergeant
5370201df8 add locks around Socket::send and Socket::recv to see if it helps with thread sanitizer error in Linux CI 2019-04-19 14:28:51 -07:00
Benjamin Sergeant
a2d170f415 fix bad merge in IXWebSocketTransport.cpp ... 2019-04-19 09:41:16 -07:00
Benjamin Sergeant
03f762db86 Socket::Poll does not need a callback 2019-04-19 09:32:49 -07:00
Kumamon38
aea859af52 Ping timeout use constant (#36)
* use constant for ping timeout

* change close code types
2019-04-19 09:16:25 -07:00
Kumamon38
5682129b1d fix close code/reason issue (#34)
* fix close code/reason issue

* added code 1006 for abnormal closure
2019-04-18 10:02:31 -07:00
Kumamon38
c3431f19bf Real ping (#32)
* close method change and fix code

* missing mutex

* wip

* renaming and fixes

* renaming, fixes

* added enablePong/disablePong, add tests

* added new test cases

* add 1 test case

* fix gcd name to greatestCommonDivisor

* move ping and ping timeout checks into socket poll, local var in test cases and indent fixes

* indent issue
2019-04-18 09:24:16 -07:00
Benjamin Sergeant
f4f60d38b8 docker + linux build fix 2019-04-17 22:52:03 -07:00
Benjamin Sergeant
4337345103 setter method does not need to return anything, make it void 2019-04-17 20:36:26 -07:00
Benjamin Sergeant
52f460f66d (doc) Add more doc to SocketServer 2019-04-17 20:36:26 -07:00
Benjamin Sergeant
d486c72e02 websocket server: closed connection threads are joined properly 2019-04-17 20:36:26 -07:00
Benjamin Sergeant
bdfc55b951 Bug/30 server connection problem (#31)
* use threads instead of std::async, need to cleanup threads

* less buggy server connection per thread system
2019-04-16 22:19:44 -07:00
Benjamin Sergeant
b0f6026c23 make closeWireSize a default parameter of WebSocketTransport::close 2019-04-16 09:55:12 -07:00
Kumamon38
b2aca491b6 close method change and fix code (#28)
* close method change and fix code

* missing mutex
2019-04-16 08:58:34 -07:00
Dimon4eg
401fc39879 fix windows build (#29)
* fix windows build

* fix for Unix

* Fix build if TLS is OFF

* add OpenSSL req to ws

* Fix build on Mac

* fix tests for windows
2019-04-16 08:51:57 -07:00
Benjamin Sergeant
37c64841ff fix warning 2019-04-13 21:16:04 -07:00
Benjamin Sergeant
804ec9246f (server) fix masking bug 2019-03-22 15:33:04 -07:00
Benjamin Sergeant
f029321664 can send TEXT message (we only support BINARY messages now) 2019-03-22 14:24:22 -07:00
Benjamin Sergeant
d41b7f64e4 unmasked code is broken 2019-03-22 14:24:15 -07:00
Benjamin Sergeant
0366d1afb9 remove printf + unittest fix 2019-03-22 09:56:28 -07:00
Benjamin Sergeant
4ef3073ca4 (server) server should not mask data when sending to client (some python client libraries enforce that and assert) 2019-03-22 09:53:56 -07:00
Benjamin Sergeant
68a53aa884 (server) HTTP response is malformed 2019-03-22 09:52:19 -07:00
Benjamin Sergeant
2358b3ff26 minor cleanup 2019-03-21 13:51:25 -07:00
Benjamin Sergeant
00ed1d2817 HTTP/1.1 response should contains a reason (websocket server)
Fix compatibility problem with websockets python library, where the response does not contains a reason

File "/.../lib/python3.7/site-packages/websockets/http.py", line 126, in read_response
version, status_code, reason = status_line[:-2].split(b' ', 2)
ValueError: not enough values to unpack (expected 3, got 2)

The above exception was the direct cause of the following exception:

websockets.exceptions.InvalidMessage: Malformed HTTP message
2019-03-21 13:43:47 -07:00
Benjamin Sergeant
5b6fdb6526 cleanup, remove dead method 2019-03-21 10:06:59 -07:00
Benjamin Sergeant
eac611ab1e Feature/connection state (#25)
* (cmake) add a warning about 32/64 conversion problems.

* fix typo

* New connection state for server code + fix OpenSSL double init bug

* update README
2019-03-20 18:34:24 -07:00
Benjamin Sergeant
0635313566 Feature/redis (#23)
* Fix warning

* (cmake) add a warning about 32/64 conversion problems.

* simple redis clients

* can publish to redis

* redis subscribe

* display messages received per second

* verbose flag

* (cmake) use clang only compile option -Wshorten-64-to-32 when compiling with clang
2019-03-20 14:29:02 -07:00
Michael Lu
663299c91e Fixed heartbeat typos (#22) 2019-03-19 21:31:43 -07:00
Benjamin Sergeant
523a6e989a make PollResultType an enum class 2019-03-19 09:29:57 -07:00
Benjamin Sergeant
13f4aee5ee fix bug with isReadyToWrite 2019-03-18 22:05:04 -07:00
Benjamin Sergeant
bbc0e2106c workaround bug in Socket::isReadyToWrite 2019-03-18 20:37:33 -07:00
Benjamin Sergeant
eb6ee52aaa use milliseconds 2019-03-18 20:17:44 -07:00
Benjamin Sergeant
a3adc49d8c disable sigpipe on osx when writing/reading into a dead pipe 2019-03-18 17:52:01 -07:00
Benjamin Sergeant
572a217050 no default parameters for isReadyToWrite and isReadyToRead 2019-03-18 14:31:21 -07:00
Benjamin Sergeant
d58798e36c when trying to flush the send buffer, use select to wait until it is possible instead of using sleep to retry at a given frequency 2019-03-18 14:25:27 -07:00
Benjamin Sergeant
e158635f57 linux hangs when closing 2019-03-16 11:38:23 -07:00
Benjamin Sergeant
68e397ab34 use pipe to abort select on Linux as well as macOS 2019-03-15 17:46:40 -07:00
Benjamin Sergeant
4c78b94cd8 missing assert include on Linux 2019-03-15 11:43:27 -07:00
Benjamin Sergeant
3a9cc9b079 cleanup 2019-03-15 11:41:57 -07:00
Benjamin Sergeant
6f90425154 linux compile fix 2019-03-14 18:55:33 -07:00
Benjamin Sergeant
49ec9b1d9e linux fixes 2019-03-14 18:54:47 -07:00
Benjamin Sergeant
a0e35ad644 build fix 2019-03-14 18:53:21 -07:00
Benjamin Sergeant
b91dc77d6f select interrupt cleanup 2019-03-14 18:37:38 -07:00
Benjamin Sergeant
b462b5a5c8 linux build fix 2019-03-14 15:17:17 -07:00
Benjamin Sergeant
b5e7fb20b6 replace uint8_t with uint64_t for the send/close requests types / use named variable to index into the _fildes array 2019-03-14 15:03:57 -07:00
Benjamin Sergeant
9d245add9c set a default close reason string 2019-03-14 14:52:51 -07:00
Benjamin Sergeant
ded03ed743 do not busy loop while sending 2019-03-14 14:48:08 -07:00
Benjamin Sergeant
5b4354a6f3 send optimization + ws file transfer test 2019-03-14 14:47:53 -07:00
Benjamin Sergeant
08c2cdbf1d send can fail silently when sending would block (EWOULDBLOCK return for send) (#18)
* try to use a pipe for communication

* flush send buffer on the background thread

* cleanup

* linux fix / linux still use event fd for now

* cleanup
2019-03-13 23:09:45 -07:00
Benjamin Sergeant
dedbeb3eab websocket send: make sure all data in the kernel buffer is sent 2019-03-11 22:16:55 -07:00
Benjamin Sergeant
d88bf16500 add new message type when receiving message fragments 2019-03-11 11:12:43 -07:00
Benjamin Sergeant
c202f8cf1d Socket code refactoring, plus stop polling with a 1s timeout in readBytes while we only want to poll with a 1ms timeout 2019-03-04 13:40:15 -08:00
Benjamin Sergeant
0c226c7629 readBytes does not read bytes one by one but in chunks 2019-03-02 21:11:16 -08:00
Benjamin Sergeant
a9e772f330 create a blocking + cancellable Socket::readBytes method 2019-03-02 15:16:46 -08:00
Benjamin Sergeant
86cc76388e create a blocking + cancellable Socket::readBytes method 2019-03-02 11:01:51 -08:00
Benjamin Sergeant
2c86fd947f Feature/http (#16)
* add skeleton and broken http client code.

GET returns "Resource temporarily unavailable" errors...

* linux compile fix

* can GET some pages

* Update formatting in README.md

* unittest for sending large messages

* document bug

* Feature/send large message (#14)

* introduce send fragment

* can pass a fin frame

* can send messages which are a perfect multiple of the chunk size

* set fin only for last fragment

* cleanup

* last fragment should be of type CONTINUATION

* Add simple send and receive programs

* speedups receiving + better way to wait for thing

* receive speedup by using linked list of chunks instead of large array

* document bug

* use chunks to receive data

* trailing spaces

* Update README.md

Add note about message fragmentation.

* Feature/ws cli (#15)

* New command line tool for transfering files / still very beta.

* add readme

* use cli11 for argument parsing

* json -> msgpack

* stop using base64 and use binary which can be stored in message pack

* add target for building with homebrew

* all CMakeLists are referenced by the top level one

* add ws_chat and ws_connect sub commands to ws

* cleanup

* add echo and broadcast server as ws sub-commands

* add gitignore

* comments

* ping pong added to ws

* mv cobra_publisher under ws folder

* Update README.md

* linux build fix

* linux build fix

* move http_client to a ws sub-command

* simple HTTP post support (urlencode parameters)

* can specify extra headers

* chunk encoding / simple redirect support / -I option

* follow redirects is optional

* make README vim markdown plugin friendly

* cleanup argument parsing + add socket creation factory

* add missing file

* http gzip compression

* cleanup

* doc

* Feature/send large message (#14)

* introduce send fragment

* can pass a fin frame

* can send messages which are a perfect multiple of the chunk size

* set fin only for last fragment

* cleanup

* last fragment should be of type CONTINUATION

* Add simple send and receive programs

* speedups receiving + better way to wait for thing

* receive speedup by using linked list of chunks instead of large array

* document bug

* use chunks to receive data

* trailing spaces
2019-02-28 21:54:03 -08:00
Benjamin Sergeant
932bb732e0 Feature/send large message (#14)
* introduce send fragment

* can pass a fin frame

* can send messages which are a perfect multiple of the chunk size

* set fin only for last fragment

* cleanup

* last fragment should be of type CONTINUATION

* Add simple send and receive programs

* speedups receiving + better way to wait for thing

* receive speedup by using linked list of chunks instead of large array

* document bug

* use chunks to receive data

* trailing spaces
2019-02-20 18:59:07 -08:00
Benjamin Sergeant
726e66ca66 unittest for sending large messages 2019-02-16 10:32:02 -08:00
Benjamin Sergeant
8983dd97a1 use dynamically generated port number to configure servers in unittest 2019-01-28 15:24:19 -08:00
Benjamin Sergeant
907605c59c windows build fix 2019-01-27 10:46:02 -08:00
Benjamin Sergeant
58921592c8 constexpr to declare number of fds 2019-01-26 21:01:36 -08:00
Benjamin Sergeant
b9c49c38ed linux fix 2019-01-26 20:57:48 -08:00
Benjamin Sergeant
76c97027c8 remove shutdown call 2019-01-26 20:54:23 -08:00
Benjamin Sergeant
5db3620f49 rebase poll branch 2019-01-26 20:50:25 -08:00
Benjamin Sergeant
a2e6fa0b16 insensitive string compare when validating server connection header 2019-01-25 16:17:51 -08:00
Benjamin Sergeant
885d245afb heartbeat correct 2019-01-25 16:11:39 -08:00
Benjamin Sergeant
75d01c0c11 close server socket on exit 2019-01-24 21:16:32 -08:00
Benjamin Sergeant
a8b6573f96 hearbeat 2019-01-24 12:42:49 -08:00
Benjamin Sergeant
121c84a2d1 check and validate the Connection: Upgrade header in client/server 2019-01-15 09:31:37 -08:00
Tony Lin
2434605c06 Fix missing upgrade header error 2019-01-15 15:35:37 +08:00
Benjamin Sergeant
a0f15bfb56 C++14 + use make_unique and make_shared to make shared pointers 2019-01-11 21:25:06 -08:00
Benjamin Sergeant
8a0afef825 check select errors better 2019-01-07 11:18:00 -08:00
Benjamin Sergeant
bf3e8195f7 DNSLookup _id member does not need to be an atomic 2019-01-06 18:32:19 -08:00
Benjamin Sergeant
bce3071a12 DNSLookup: fix #8 2019-01-06 18:27:26 -08:00
Benjamin Sergeant
911f684e4d DNSLookup: copy hostname and port instead of accessing member 2019-01-06 18:17:12 -08:00
Benjamin Sergeant
49bc156a56 return false -> return -1 2019-01-06 18:10:39 -08:00
Benjamin Sergeant
372af54e46 remove dead file 2019-01-06 14:26:11 -08:00
Benjamin Sergeant
2f9ad54bae gcc linux compile fix 2019-01-06 12:12:39 -08:00
Benjamin Sergeant
57c22cddb8 make a class hierarchy for server code (IXWebSocketServer <- IXSocketServer) 2019-01-06 12:09:31 -08:00
Benjamin Sergeant
60dc765178 unittest + compiler warnings 2019-01-05 21:10:08 -08:00
Benjamin Sergeant
5e1c150024 windows compile fix 2019-01-05 21:02:55 -08:00
Benjamin Sergeant
0fd06bb592 int -> ssize_t for socker recv and send 2019-01-05 20:53:50 -08:00
Benjamin Sergeant
9641c8cf49 header refactoring 2019-01-05 20:38:43 -08:00
Benjamin Sergeant
4ca31be4a2 windows connect (compile fix) 2019-01-05 17:35:50 -08:00
Benjamin Sergeant
667f18cbfe windows connect potential fix 2019-01-05 17:32:21 -08:00
Benjamin Sergeant
4df5050760 more accurate description of errors 2019-01-05 17:18:43 -08:00
Benjamin Sergeant
b80696af00 windows (compile) fix 2019-01-05 17:04:09 -08:00
Benjamin Sergeant
3cb2f6dcf7 windows fix 2019-01-05 17:02:39 -08:00
Benjamin Sergeant
89ff9dd5ac fix gcc warning 2019-01-05 16:26:11 -08:00
Benjamin Sergeant
e892b21872 openssl cleanup 2019-01-05 11:42:25 -08:00
Benjamin Sergeant
3eef8fba27 unittest on appveyor 2019-01-04 17:28:13 -08:00