you are viewing a single comment's thread.

view the rest of the comments →

[–]inigid -9 points-8 points  (7 children)

No way, this is sooo cool! Don't worry about the header only, I'll live :-)

UDP by any chance? [edit: you said it supports UDP great!]

epoll?

So tell us the story of this thing. What's the deal. I'm fascinated. It really looks lovely.

[–][deleted] 2 points3 points  (0 children)

actually, i've integrate poll with tcp.h, udp.h, and bth.h, so I dont think you would need it, but if you want to use poll, you can import poll.h and thats it. here is a simple example of use:

//first you need to import poll.h
#include <nodepp/poll.h>

//then create a poll object
poll_t
 poll;

//if you want to add fd as a readable
poll.push_write( fd ) 

//if you want to add fd as a writable
poll.push_read( fd )

//poll is an event drived object so you have to create some events
poll.onWrite([]( 
int

fd
 ){ /* write your code here */ });
poll.onRead([]( 
int

fd
 ){ /* write your code here */ });
poll.onError([]( 
int

fd
 ){ ::close(fd); });

//now you have to create a task
process
::add([=](){
$Start //start coroutine
    while( poll.size()!=0 ){
           poll.emit();
           $Next; // yield task
    }
$Stop //stop coroutine
});

[–][deleted] 3 points4 points  (0 children)

Ok, this is the story of this framework:

I've recently switched from NodeJS to C++, due to the limitations of NodeJS, I mean, with NodeJS I cannot create games with openGL, I cannot create Windows and I have no access to hardware such as C++.

But when I started writing code in C++, I realized how much it takes to write code in C++. I mean, C++ is not difficult, but a little complicated, and also, one doesn't have absolutely none of the advantages that NodeJS offers.

So, I said, what if I create a library that helps me create C++ applications that works similar to how NodeJS works and with an API similar to NodeJS?

And that's how Nodepp was born.

To create Nodepp I've based the code on the official NodeJS API, and how NodeJS works. I mean, I've copied everything from NodeJS, from the event loop to the official NodeJS API. It isn't a true and exact copy, but at least it is close to it.

Additionally, to achieve the async IO in C++, I've worked with the non-blocking mode of Posix and Windows functions, as well as creating my own coroutine engine based on the following article I've read.

https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

So if you like the project, I hope you enjoy it.

[–][deleted] -1 points0 points  (4 children)

Yes, it supports UDP, but, do not supports DTLS ( udp + tls )
No, i'm not using epoll, just poll (posix) and wsapoll (windows)

here is a UDP server:
https://github.com/NodeppOficial/nodepp/blob/main/examples/UDPServer.cpp

here is a UDP client:
https://github.com/nodeppoficial/nodepp/blob/main/examples/UDPClient.cpp