Thousandth Cycle Celebration - TCP Server in C++ (Unix sockets)
the repl DOES NOT WORK ON REPLIT. Any attempts to connect to this repl should fail with. Error 502 or something like that.
To celebrate getting 1000 cycles, I’ve decided to post this repl I made a couple weeks ago. It’s a class that creates a TCP server, with connections being handled by a supplied callback in an asynchronous fashion. I think. #include Server.hpp in your main.cpp or wherever it is you want to use it.
When constructing a Server, you must pass 3 arguments:
- a callback function (used to handle tcp connections, must return void and take a file descriptor and
- a port number (should actually be a string literal, best between 1030-6500 I think)
- a Boolean. (This tell me whether or not you want me to automatically close connections for you after the handler function has been called)
After having made the server you then must call the start() function in order for it to actually begin accepting connections. The start() function takes one argument (an int), which tells me how many threads you want running at once to handle connections. It returns a vector of all those threads, including a separate thread that actually accept()s connections as the last one.
I was gonna try and make a chat server out of it as an example, but got bored and unmotivated due to the extremely frustrating and unhelpful quality of this class I made.
I hope you like it.
Edit: oh also it doesn’t work on repl.it unless you make your requests and responses look like they follow HTTP, so... yeah.... That’s not too hard though so don’t sweat it I’ll be including the RFC for HTTP/1.1 here soon and I was thinking about maybe making a second class / lib type thing that parses/generates HTTP packets for you, but don’t count on it.
Edit2: the RFC for HTTP/1.1 is at http://tools.ietf.org/pdf/rfc7230.pdf
Edit3: just tried it with a package that should have been accepted. Didn’t work. :(
note: NOT in chronological order
LizFoster also took a break from repl.it around the same time you did. She stopped posting completely. She's still working on her Pokemon game though
TheDrone7 (mod) has been very active! He has a #Weekly Challenges series he posts every week. Solve the challenge, and the winner after a month gets free hacker plan! Here's the result of last month, and for this month, we've only done one. 3 more to go! He also posts a list of some cool repls in May. And, he's been releasing some cool developer spotlights. There fun to read.
I got quite a lot of cycles after releasing some arcade games, and some other projects. CodingCactus has 2200 now, CoderGod has 2300, Bookie has 2100, and couple more jumps.
BramJam Game Jam happened! That was pretty cool! Next one's in august I think
It's pride month, that's why me and quite a few other people have rainbow backgrounds.
Some changes to repl.it - the trending algorithm is harder now so low quality posts can't get on easily. Also better support for Git and GitHub. Also audio
We (the community) actually had a HUGE debate over cycles, Amasad and a couple other mods got involved, and basically it was about cycle farming, and begging for cycles, and all that stuff. So now, I wouldn't recommend saying "And don't forget to upvote!" or something similar in your posts anymore, since some people hate it and won't uvpote your posts because of that
And yeah, that's pretty much it I think :)
- aw. Well at least she’s probably getting more sleep lol.
- noice! I’ve seen quite a few try but no one ever seemed able to actually get into it...
- 👏 ohh yeah. LOTS of cycles lol. F’ing 1451 that)s just so sick I wish I’d been able to capitalize on the covid-19 shut-in like that.
- ? Never heard of it... sounds cool though!
- I wonder if I can find a rainbow version of a zombie getting shot.... I actually like your rainbow version a lot, even better than your old background it’s super cool ^ ^
6 & 7) FINALLY! too them long enough XD I’m glad. Hum. I did do that once, didn’t I?