Impensus Posted April 19, 2019 Share Posted April 19, 2019 Hi guys, I am attempting to create a socket based muling system but I have a few questions about the integration. When using sockets on a certain port will I have to create a multi-threaded listening script on the server? Would it instead work to just send the request and expect a reply and if the server was busy dealing with the request to wait a random amount of time 1-2 seconds and send again? Obviously with 100-200 accounts the chance of two muling at the same time is quite low but still it can happen, especially as my farm scales. Also I heard occasionally that sockets/ certain aspects of sockets are disabled in Osbot, can anyone clarify what I am limited to with sockets? Thanks guys! Quote Link to comment Share on other sites More sharing options...
dazeldo Posted April 19, 2019 Share Posted April 19, 2019 The bots all have to be clients, can't run a server from within script. I think making it multi-threaded is your best bet. Quote Link to comment Share on other sites More sharing options...
Impensus Posted April 19, 2019 Author Share Posted April 19, 2019 6 minutes ago, dazeldo said: The bots all have to be clients, can't run a server from within script. I think making it multi-threaded is your best bet. I am running an external server and attempting to connect to the server via sockets. The server code will take bot mule requests and return a mule name and location + prompt the mule to login. My question is can I get away with making it not multi-threaded and just listen on one port as there will be very very few times requests would overlap? Quote Link to comment Share on other sites More sharing options...
dreameo Posted April 19, 2019 Share Posted April 19, 2019 As a server: -Accepting new clients is a blocking event -Reading from a client stream is a blocking event You can combine all client streams into a single stream and listen to that single stream which only requires one thread. In doing so, each message must include data to distinguish one client from another. So that you know who to reply back to as a server. Regarding accepting clients, this has to be done in another separate thread. You just have to make sure that you continue to accept and not block other requests. If not, a timeout will be caused by the client and the connection will fail. You should just play around in an IDE without any kind of bots and just figure out how to do this. Just basic message passing between client(s) and server. Quote Link to comment Share on other sites More sharing options...
Impensus Posted April 19, 2019 Author Share Posted April 19, 2019 23 minutes ago, dreameo said: As a server: -Accepting new clients is a blocking event -Reading from a client stream is a blocking event You can combine all client streams into a single stream and listen to that single stream which only requires one thread. In doing so, each message must include data to distinguish one client from another. So that you know who to reply back to as a server. Regarding accepting clients, this has to be done in another separate thread. You just have to make sure that you continue to accept and not block other requests. If not, a timeout will be caused by the client and the connection will fail. You should just play around in an IDE without any kind of bots and just figure out how to do this. Just basic message passing between client(s) and server. To combine all client streams would I have to make a sort of 'server'/central application client side that takes the message from the client and then transfers that +messages from any other client to the server then gathers the responses and distributes them accordingly? Quote Link to comment Share on other sites More sharing options...
dreameo Posted April 19, 2019 Share Posted April 19, 2019 43 minutes ago, Impensus said: To combine all client streams would I have to make a sort of 'server'/central application client side that takes the message from the client and then transfers that +messages from any other client to the server then gathers the responses and distributes them accordingly? No, there's a stream or a class that allows you to combine streams into one. 1 Quote Link to comment Share on other sites More sharing options...
dreameo Posted April 19, 2019 Share Posted April 19, 2019 It's much easier to do everything via a HTTP server and REST API. 2 Quote Link to comment Share on other sites More sharing options...