adrien changed the topic of #ocaml to: Discussions about the OCaml programming language | http://www.ocaml.org | OCaml 4.08 release notes: https://caml.inria.fr/pub/distrib/ocaml-4.08/notes/Changes | Try OCaml in your browser: http://try.ocamlpro.com | Public channel logs at http://irclog.whitequark.org/ocaml
Haudegen has quit [Ping timeout: 258 seconds]
_whitelogger has joined #ocaml
nullnullnull has joined #ocaml
mfp has quit [Ping timeout: 245 seconds]
Netsu has quit [Ping timeout: 260 seconds]
assemblyman has joined #ocaml
hio has joined #ocaml
delysin has joined #ocaml
nullnullnull has quit [Quit: Leaving]
iovec has quit [Quit: Connection closed for inactivity]
delysin has quit [Quit: WeeChat 2.5]
Netsu has joined #ocaml
delysin has joined #ocaml
assemblyman has quit [Quit: ™]
gravicappa has joined #ocaml
Jeanne-Kamikaze has joined #ocaml
nullnullnull has joined #ocaml
Netsu has quit [Ping timeout: 260 seconds]
<nullnullnull> let ad=ADDR_INET ((gethostbyname "google.com").h_addr_list.(0),80)
<nullnullnull> how can I add a timeout there? for example 1 sec
ggole has joined #ocaml
zolk3ri has joined #ocaml
Jeanne-Kamikaze has quit [Quit: Leaving]
klntsky has quit [Remote host closed the connection]
klntsky has joined #ocaml
kakadu has joined #ocaml
sagax has joined #ocaml
JimmyRcom has quit [Ping timeout: 245 seconds]
gareppa has joined #ocaml
themsay has quit [Ping timeout: 245 seconds]
themsay has joined #ocaml
Haudegen has joined #ocaml
gareppa has quit [Quit: Leaving]
hannes has joined #ocaml
<nullnullnull> anyone knows how to set socket timeout? ADDR_INET ((gethostbyname "google.com").h_addr_list.(0),80)
<dmbaturin> nullnullnull: I once knew it. Let me see.
<dmbaturin> nullnullnull: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html look for setsockopt_float
mfp has joined #ocaml
<nullnullnull> dmbaturin, thanks mate :) I will look there
<hannes> .but then gethostbyname hides the socket from you... .oO(what would you like to timeout, the connect or the getaddrinfo?)
<nullnullnull> hmmm
<nullnullnull> why not both? ;)
<hannes> TL;DR: it's complicated. I don't know how you'd do it for gethostbyname. for connect, the TCP stack actually already has an established_timeout (but as dmbaturin pointed, you can setsockopt SO_RCVTIMEO)...
<nullnullnull> can I do it with another way? like using threads timeout or anything related
<hannes> (and than if i read correctly https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_10_16 it's only the recv/read, not the connect)
<hannes> nullnullnull: likely (but I'm not very knowledgable in programming with posix threads (+OCaml), sorry)
<nullnullnull> hannes, btw I'm new to OCaml ;)
<dmbaturin> In practice it should work for connect on most platforms I think.
<hannes> nullnullnull: in case you plan to use lwt (an asynchronous task library -- http://ocsigen.org/lwt/4.1.0/api/Lwt) --> this one has Lwt.pick [ do_my_connection ; Lwt_unix.sleep 3. ]
<nullnullnull> yeah I'm trying to not use any external library
carlosdagos has joined #ocaml
<nullnullnull> I saw the "Lwt" and the "utop" thing but need to install the libraries
<dmbaturin> utop is a lot better than the default REPL.
bacam has quit [Quit: reboot]
<nullnullnull> dmbaturin, btw mate I didnt test the setsockopt yet, is it working with hostname?
bacam has joined #ocaml
<dmbaturin> I can't imagine my life without utop.
<dmbaturin> nullnullnull: It takes the socket file descriptor. Once you have it, you can set any options.
<nullnullnull> yeah im trying to figure out how to do it, I just started to learn OCaml today ;)
<dmbaturin> Sockets is a rather unusual place to start learning. ;)
<Armael> not sure if it's relevant for what you're trying to do, but https://ocaml.github.io/ocamlunix/ is a good resource wrt unix system programming in ocaml
<Armael> damn.
<Armael> dmbaturin was faster
<nullnullnull> thanks guys :) I will learn from there
<Armael> but generally speaking, for low level socket manipulation and the like, the ocaml APIs just mirror the unix ones
<Armael> so I usually just google for solutions in C and the ocaml solution is a one-to-one adaptation
<Armael> (or, as noted by hannes, you could use Lwt that provides higher level, asynchronous APIs)
<dmbaturin> I have an example of a simple multi-client server with Lwt if it helps: https://baturin.org/code/lwt-counter-server/
<dmbaturin> Doesn't discuss timeouts though.
<nullnullnull> hmm
<nullnullnull> btw this is for C: ________ if(setsockopt(s,SOL_SOCKET,SO_SNDTIMEO,(const void*) &timeout,sizeof(timeout))!=0 || connect(s,(struct sockaddr *) &sa,sizeof(sa))<0) return 1;else close(s)
<nullnullnull> the threads = external library right?
<Armael> "the threads"?
<dmbaturin> No, there are built-in threads.
<nullnullnull> Armael, sec I will take a look there
<Armael> everything that's in the ocamlunix book only uses the standard library, afaik
<dmbaturin> It's an old book, too. It predates many of the libs anyway. :)
<nullnullnull> yeah I figured out why the "threads" didnt work for me
<nullnullnull> I ran with ocaml not ocamlc
<nullnullnull> ocamlc -thread unix.cma threads.cma
<Armael> but note that if you can do it in C without ptheads, you can do it in ocaml without threads as well
<Armael> you can do something similar to your C snippet above
<nullnullnull> hmm
<Armael> it should work just the same
<nullnullnull> thanks mate :) I will see
mfp has quit [Ping timeout: 245 seconds]
brett-soric has joined #ocaml
dmiles has joined #ocaml
dimitarvp has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
brett-soric has left #ocaml [#ocaml]
dimitarvp has quit [Quit: Bye]
RalfJ has quit [Remote host closed the connection]
RalfJ has joined #ocaml
dmiles has quit [Ping timeout: 258 seconds]
jnavila has joined #ocaml
dmiles has joined #ocaml
JimmyRcom has joined #ocaml
_whitelogger has joined #ocaml
Birdface has joined #ocaml
Birdface has quit [Remote host closed the connection]
mfp has joined #ocaml
nullnullnull has quit [Quit: Leaving]
FreeBirdLjj has joined #ocaml
carlosdagos has quit [Read error: Connection reset by peer]
carlosdagos has joined #ocaml
FreeBirdLjj has quit [Remote host closed the connection]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 245 seconds]
sillyotter has joined #ocaml
sillyotter has quit [Client Quit]
slice has quit [Ping timeout: 250 seconds]
slice has joined #ocaml
cgt has joined #ocaml
rosterok has quit [Quit: Connection closed for inactivity]
FreeBirdLjj has joined #ocaml
FreeBirdLjj has quit [Ping timeout: 246 seconds]
cgt has quit [Read error: Connection reset by peer]
cgt has joined #ocaml
Haudegen has quit [Quit: Bin weg.]
Serpent7776 has joined #ocaml
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
jnavila has quit [Ping timeout: 252 seconds]
oni-on-ion has quit [Ping timeout: 264 seconds]
ziyourenxiang_ has quit [Ping timeout: 246 seconds]
themsay has quit [Read error: Connection reset by peer]
themsay has joined #ocaml
AtumT has joined #ocaml
tane has joined #ocaml
louisg has quit [Ping timeout: 248 seconds]
Haudegen has joined #ocaml
Jeanne-Kamikaze has joined #ocaml
jnavila has joined #ocaml
zolk3ri has quit [Remote host closed the connection]
louisg has joined #ocaml
jnavila has quit [Ping timeout: 246 seconds]
Haudegen has quit [Quit: Bin weg.]
Haudegen has joined #ocaml
AtumT_ has joined #ocaml
AtumT has quit [Ping timeout: 248 seconds]
AtumT has joined #ocaml
AtumT_ has quit [Ping timeout: 248 seconds]
tane has quit [Quit: Leaving]
Anarchos has joined #ocaml
Anarchos has quit [Client Quit]
Anarchos has joined #ocaml
ggole has quit [Quit: Leaving]
gravicappa has quit [Ping timeout: 246 seconds]
bitwinery has quit [Remote host closed the connection]
bitwinery has joined #ocaml
Anarchos has quit [Quit: Vision[0.10.3]: i've been blurred!]
bitwinery has quit [Ping timeout: 248 seconds]
kakadu has quit [Remote host closed the connection]
bitwinery has joined #ocaml
liberiga has joined #ocaml
bitwinery has quit [Quit: Leaving]
oni-on-ion has joined #ocaml
Serpent7776 has quit [Quit: leaving]
Jesin has joined #ocaml
bluemanblue has joined #ocaml
<bluemanblue> does anyone know an easy fix to this type error when trying to make any of the languages presented in Pierce's TPL (accompanying ocaml code)
<bluemanblue> [warrick@warrick-pc arith]$ make
<bluemanblue> ocamlc -c lexer.ml
<bluemanblue> Use Bytes.create instead.
<bluemanblue> Warning 3: deprecated: Stdlib.String.create
<bluemanblue> File "lexer.mll", line 96, characters 24-37:
<bluemanblue> File "lexer.mll", line 105, characters 23-29:
<bluemanblue> Error: This expression has type bytes but an expression was expected of type
<bluemanblue> string
<bluemanblue> make: *** [Makefile:54: lexer.cmo] Error 2
<Armael> a quick fix would be to use an older version of ocaml
<Armael> the errors are because strings are now immutable
<bluemanblue> thanks - is there any easy recommended way of doing this? e.g. some kind of haskell stack equivalent?
<Armael> yeah there's opam
<Armael> does TPL indicates what is the expected version of ocaml?
<Armael> after you install opam, you'd typically do 'opam init' and then 'opam switch the_ocaml_version' to compile the version you want
<bluemanblue> couldn't find it, no idea but I'm guessing that its 5+ years old
<bluemanblue> will try opam now, thanks
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
themsay has quit [Read error: Connection reset by peer]
themsay has joined #ocaml
liberiga has quit [Ping timeout: 260 seconds]
oni-on-ion has quit [Remote host closed the connection]
oni-on-ion has joined #ocaml
ziyourenxiang_ has joined #ocaml
keep_learning has joined #ocaml
bitwinery has joined #ocaml
bitwinery has quit [Remote host closed the connection]
bitwinery has joined #ocaml
Haudegen has quit [Quit: Bin weg.]