Fork me on GitHub
#off-topic
<
2018-05-18
>
benzap03:05:21

So i'm not that familiar with socket programming, but i've gotten as far as an telnet echo server. However, i'm running into an issue with the first few socket inputs being clobbered with additional characters.

benzap03:05:04

This is when I try and connect to the socket through Putty with telnet

benzap03:05:15

is there something in the telnet protocol that i'm supposed to account for?

dpsutton03:05:49

Can you get the bytes of those and compare them to syn and ack?

benzap03:05:51

I always assumed that it was just a barebones socket reader, and wrote text to the output with a CRCF

benzap03:05:29

i'm on windows, but i'll see if I can do something similar

dpsutton03:05:50

On a whim, I tried telling Putty to use a Raw connection instead of Telnet:

benzap03:05:13

oh, good idea

dpsutton03:05:22

I googled that symbol. It's a common problem. I'm on mobile so hard to share

benzap03:05:48

interesting, that solved the problem

benzap03:05:05

so telnet must be including some extra control characters in there that i'm not aware of

benzap03:05:33

ahh that stackoverflow answer is great, I have some reading to do πŸ™‚

benzap07:05:53

I got a socket repl working for my fif stack-based language https://i.imgur.com/Rwdh9eD.png

benzap07:05:08

I basically stole the clojure.server implementation introduced recently and wrote something similar for fif

benzap07:05:56

What i'm curious about is whether or not I could Create a native-image in graalvm which includes a fif socket repl as a means of controlling the software other than a clojure socket repl, which doesn't work due to invokeDynamic

benzap07:05:36

from what I can tell, I don't think my scripting language makes use of anything dynamic

hjozwiak12:05:16

Hi all.

πŸ‘‹ 4
parrot 4
jgh12:05:18

@benzap use netcat instead of telnet if you’re testing a plaintext socket implementation

benzap19:05:32

@jgh thanks for the heads up, i'll give it a try

souenzzo20:05:27

There is some cloud service that send's a http request to my app every x minutes?

dominicm20:05:56

CloudWatch can be configured to do that I believe.

dominicm20:05:12

I think there's also some cron websites kicking about that do it too.

dominicm20:05:18

Why would you want to, might I ask?

souenzzo20:05:00

I need to "update global players ranking" every 30 minutes. But I'm thinking in a auto-scale application, so quartz may be complex. If every 30 minutes "someone else" send a external HTTP request asking to update, will be way easier

val_waeselynck20:05:07

I use SetCronJob for that

souenzzo20:05:04

scaling (multiple instances) problem

dominicm20:05:48

(doto
  (Thread.
    (fn []
      (while true
        (update-ranking!)
        (Thread/sleep (* 30 1000))))  ;; TODO: Check dominic's math
  (.start))
@souenzzo would this work ^^ πŸ˜›

souenzzo20:05:35

What if there is 200 micro-instances running?

dominicm20:05:54

Ah, you're at scale already πŸ™‚

souenzzo20:05:56

(on the same DB and update-ranking writes on db)

dominicm20:05:42

Quartz is one option. The other is to spin this up as something that sits in a box that never "scales".

souenzzo20:05:43

Yeah. at the moment I'm using quartz

dominicm20:05:32

The benefit of having it on a box that doesn't scale is that it keeps the performance cost off your main handling machines. If it takes longer to generate the index for some reason, it shouldn't slow down the main service.

dominicm20:05:54

The load balancing algorithms aren't always aware of the CPU utilization of a node, I think round-robin is more common.

souenzzo20:05:39

I think that my case I will do a single machine that calls HTTP on balancer.

dominicm20:05:04

https://www.easycron.com/ <-- I think it was this one, or something very similar, that we used in the past.

dominicm20:05:03

https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/WhatIsCloudWatchEvents.html also CloudWatch can do a lot if you're using AWS already.

πŸ‘ 4
dominicm20:05:29

Your job might suit a lambda perhaps, if it's under 5 minutes?

souenzzo20:05:21

May I need to (re) configure this times at runtime. Maybe some "single call at this day" too

valtteri06:05:59

If you create a lambda-function that does the HTTP call you can invoke it manually anytime (in addition to scheduled invocations by CloudWatch).

dominicm20:05:15

(while true) would work as well as the loop/`recur`