FreeDSx / SNMP

A Pure PHP SNMP Library.
MIT License
57 stars 13 forks source link

reactPHP #19

Open skydiablo opened 1 year ago

skydiablo commented 1 year ago

hey! your lib seems to be in the right direction! what do you think to add reactPHP support?

ChadSikorra commented 1 year ago

Hi there @skydiablo. I have received a similar request on my ldap library. I think it's possible, but it's a large effort.

All of the socket based code currently resides in the "freedsx/socket" library and is shared between my snmp and ldap projects. I would need to create an interface for the socket code that allows for different adapters (like ReactPHP) for the underlying transport. I would need to account for both synchronous and asynchronous socket based communication in the interface with something like ReactPHP.

I'm not opposed to it, but I'm not sure if it's something I'll be able to add soon (personal life and work has been quite busy lately). Funny enough, I believe this library would work fine in something like Swoole since it modifies the underlying socket resource to be compatible with coroutines.

skydiablo commented 1 year ago

here is my first draft

ChadSikorra commented 1 year ago

Hey there @skydiablo , apologies for my delayed response. I've glanced over the PR / branch you have for ReactPHP. I appreciate the effort you took for these changes. I do have a couple of thoughts on it.

I like the interface you have created for the socket. That is something that would be needed to provide integration with async networking libraries like ReactPHP / Swoole / etc. I think that SocketInterface should actually live in freedsx/socket. And the ReactPHP implementation of the socket would either live in that library as an optional dependency (definitely not a requirement for general use of this library) or even its own freedsx/socket-reactphp repo.

My ultimate goal would be to have no external dependencies directly in this library for something like ReactPHP. The client protocol handler / rest of the logic should be able to function without being aware of the underlying network communication type. Mostly because it's completely reasonable to use this library without a need for the async nature of a library like ReactPHP.

That said, as a proof of concept that looks pretty good without a ton of huge changes.

skydiablo commented 1 year ago

Hey, cool that you review my stuff. I have already more optimazations but Not pushed yet. For sure, a dedicated Socket lib ist currently Not needed, as you can See. Also no other lib will needed this Socket lib. A more abstraction layer that will Wrap reactPHP and other async libs will be fine but currently Not my Focus. So i have me already commited to reactPHP and No other solution ist needed. I know, this ist Not realy fair but i have already thinking to rebrand your lib for an dedicated reactPHP solution, Like a "hard fork" ... I do Not think that you have the time to optimize/rewrite your current lib to Support reactPHP... Or i'm wrong, would you Like to Invest some more time and we Go together in Same direction?

Regards, Volker.

EDIT: i have updated the branch with lates patches!