dark_light changed the topic of #ocaml to: OCaml 3.09.2 available! Archive of Caml Weekly News: http://sardes.inrialpes.fr/~aschmitt/cwn/ | A free book: http://cristal.inria.fr/~remy/cours/appsem/ | Mailing List: http://caml.inria.fr/bin/wilma/caml-list/ | Cookbook: http://pleac.sourceforge.net/
TSC has joined #ocaml
jcreigh has joined #ocaml
pango__ has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
pango has quit [Remote closed the connection]
jcreigh has joined #ocaml
ziggurat has joined #ocaml
ziggurat has quit ["Leaving"]
<araujo> hello
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
ziggurat has joined #ocaml
shekmalhen has joined #ocaml
mnemonic has joined #ocaml
<mnemonic> hi
Cowmoo has joined #ocaml
Cowmoo has left #ocaml []
youknow365 has joined #ocaml
<youknow365> ocaml can be programmed in a procedure way right? .......Like C ?
<shekmalhen> why?
<youknow365> im not used to the whole functional way
<youknow365> but i would like to se Ocaml
<youknow365> 2ndly it is stated if you write ocaml code in C structure it will run faster
<youknow365> but i like ocaml syntax way better then C
<shekmalhen> yeah... but if you write C in C style, it will be even faster :)
<youknow365> lol
<youknow365> but i like ocaml ......easier /looks better then C and not as confusing
<shekmalhen> but... by "C structure", you mean iterative programming?
<youknow365> whatever C uses
<youknow365> not the functional stuff
<shekmalhen> yeah
<shekmalhen> you can
<youknow365> i would rather do that .......then t ochange my whole way of thinking
<araujo> mm..
<araujo> doing that is pretty much killing the expressiveness and cleanness of functional programming
<araujo> probably ending up with c-like code :-)
<youknow365> blah
<youknow365> C code looks horrible syntax wise
<youknow365> and makes it 30 times more confusing
<shekmalhen> considered trying a cleaner imperative language?
<youknow365> like ?
<shekmalhen> what do you favour?
<youknow365> i dont know give me some names
<shekmalhen> speed? readability? security?
<youknow365> compiled languages
<youknow365> speed and readability
<shekmalhen> None :P
<youknow365> what do you have in mind ?
<youknow365> i think ocaml is pretty readable
<shekmalhen> compiled and readable, secure, maybe Ada95 :)
<shekmalhen> but it is slow
<youknow365> that ada seems old as shit
<youknow365> and to me ......looked really wierd almost BASIC ish
* shekmalhen used to love this language
<shekmalhen> well... it is verbose
<shekmalhen> and mostly make a lot of sense
<shekmalhen> It is made to be read
<shekmalhen> rather than written
<shekmalhen> but it is a bit too verbose
<shekmalhen> it takes long to write programs with it
<youknow365> it looked really funky to me
<youknow365> not for me :P
<shekmalhen> but not much debuging, tho
<shekmalhen> 'k
<youknow365> ocaml looked alot easier
<shekmalhen> ?!
<youknow365> ocaml syntax looks alot easier
<shekmalhen> caml's syntax is pretty much funky.
<youknow365> ok well man like i said that Ada crap remindined me of COBOL
* araujo almost with a year without using ocaml
<youknow365> bash-3.1# ocamlc unix.cma -o tcp.ml
<shekmalhen> not very popular in enterprises?
<shekmalhen> :)
<youknow365> thats how you compile right ?
<youknow365> i included unix.cma casue i am using sockets
<shekmalhen> -o means output file
<youknow365> oo yea
<youknow365> bash-3.1# ocamlc unix.cma tcp.ml -o tcp
<youknow365> like thaat ?
* araujo been using Haskell for all this time
<araujo> but i am interested to look into ocaml's scripting capabilities :-)
<shekmalhen> 'k
<shekmalhen> never tried haskel yet
<shekmalhen> youknow365, seems better
<araujo> shekmalhen, a beautiful language
<araujo> though i think ocaml got better support for scripting
<shekmalhen> by scripting you mean?
* shekmalhen is generally not fond of "pure" languages
<araujo> to manipulate other programms and processes
Snark has joined #ocaml
<shekmalhen> 'k
<shekmalhen> with ocaml's unix module?
<araujo> shekmalhen, they are beautiful in its own way.
* araujo has used mostly pure languages
<araujo> shekmalhen, yes, and the fact you can use ocamlrun to interpret programms
<araujo> from commandline that is
<shekmalhen> but you need to bytecompile the program first
<shekmalhen> maybe using a toplevel?
<araujo> Though i _do_ understand that pure languages usually build too many theoretical barriers which people wouldn't like to mess with
<shekmalhen> my idea is to use what's best for this situation.
<araujo> shekmalhen, you mean, with ocamlrun?
<shekmalhen> multi-paradigm languages offer more freedom in this manner
<shekmalhen> araujo, no, ocaml and other toplevels created by ocamltop
<araujo> well, i am pretty much re-learning ocaml , i checked you can write a programm with #!/usr/bin/ocamlrun , a la shell script...
<araujo> shekmalhen, yes , it is not like pure languages aren't able to use other paradigms. But that usually implies some kind of emulation which the user doesn't want to deal with.
<araujo> My point about the theoretical aspects.
<shekmalhen> I see
<shekmalhen> and it is perfectly valid.
<araujo> That got many cons and pros , it pretty much depends upon what you want to use.
<youknow365> syntax error line 10 ?
<youknow365> any ideas?
<shekmalhen> But I try to find languages as tools, so I can do better work, faster and everything
<araujo> shekmalhen, yes, that's one way of looking at languages.
<araujo> There are many more.
<shekmalhen> of course!
<shekmalhen> :)
<shekmalhen> and I don't invalidate your point of view
<araujo> Sadly, pure languages haven't been able to fit well into the 'tools-to-do-the work' view
<shekmalhen> no flame war :P
<araujo> :-)
<youknow365> any help with my syntax error ? :P
<araujo> youknow365, wait a week so i can re-read ocaml stuff
<araujo> :-)
<youknow365> lol :(
<youknow365> i dont think theres any problem wihth line 10 i think its something else casuing it
<araujo> shekmalhen, good book for learning ocaml on english?
<shekmalhen> not really, I've been reading stuff on web lately
<youknow365> whats wrogn with my little simple tcp client ?
<youknow365> let client_sock = Unix.socket PF_INET SOCK_STREAM 0 in
<youknow365> anyone see a problem with that ?
* shekmalhen added a ; at the end of the function and got other errors :
<shekmalhen> :)
mnemonic has quit ["leaving"]
<araujo> shekmalhen, what do you use ocaml mainly for?
<shekmalhen> presently, I learning it :)
<shekmalhen> Trying to see what I could do with it
<shekmalhen> can
<shekmalhen> it seems pretty general
<araujo> nic
<araujo> nice even
<shekmalhen> and you?
<shekmalhen> what do you use ocaml and haskell for?
<shekmalhen> youknow365, where are you now?
<youknow365> i am back
<araujo> shekmalhen, i used ocaml to write a small package manager around one year ago
<araujo> i use haskell for writing practically anything i want :-)
<araujo> except scripting stuff
<youknow365> so about my line 10 syntax problem
<youknow365> let client_sock = Unix.socket PF_INET SOCK_STREAM 0 in
<youknow365> grrrrrrr
<youknow365> any of you know the problem......or even know ocaml :D
<shekmalhen> youknow365, 'k
<shekmalhen> try this
<shekmalhen> camlp4 pa_o.cmo pr_o.cmo $source_file
<shekmalhen> where $source_file is your source file
<youknow365> it just displayed the code ?
<shekmalhen> the code is parsed and dumped back.
<shekmalhen> It might help to see what the parser understand
<youknow365> its the same
<youknow365> formatted al ittle different
<youknow365> shekmalhen: what does that mean when its parsed ?
<youknow365> i dont get what its doing
<youknow365> or how it could help me
<shekmalhen> the compiler and the interpreter need to read and understand the program text
<shekmalhen> it is parsing.
<shekmalhen> It stores it in memory in a way that it makes sense to it so it could either execute the code or make bytecode or machine code out of it
<shekmalhen> but what I gave you dump the program back in ocaml form.
<youknow365> what it gave back is a little different then what i have ?
<shekmalhen> yeah
<youknow365> not much but a little
<youknow365> what does this mean
<shekmalhen> but it is really the way that it understand the program
<youknow365> so what can i accomplish bvyt doing this ?
<shekmalhen> if there was a slight syntax error, it would show up drastically different
<shekmalhen> it is a tool that can help you to understand what is happening; it is useful when you have too few information about the problem and that the parser gives cryptic error messages
<youknow365> it just says syntax error line 10
<youknow365> but
<youknow365> let client_sock = Unix.socket PF_INET SOCK_STREAM 0 in
<youknow365> look ok to me
<youknow365> do you see anything wrong there ?
<shekmalhen> here, it won't compile
<youknow365> whats it say ?
<youknow365> File "tcp.ml", line 10, characters 52-54:
<shekmalhen> File "ff2.ml", line 11, characters 2-9:
<shekmalhen> This function is applied to too many arguments,
<shekmalhen> maybe you forgot a `;'
<youknow365> wtf'
<shekmalhen> :)
<youknow365> how are we getitng different shit ?
<shekmalhen> I modified it a bit
<youknow365> oooooo
<youknow365> well lol
<shekmalhen> added "open Unix" at the top of the file
<shekmalhen> and I'm trying to compiled the pretty printed version
<youknow365> theoretically if i didnt have htis syntax error itlooked like it would work
<shekmalhen> :)
<youknow365> yea
<youknow365> if you add open Unix
<youknow365> you dont have to put unix. right ?
<shekmalhen> but... I see four arguments to Unix.connect while it only takes 2
<shekmalhen> yes
<youknow365> what
<youknow365> Unix connect is never used
<shekmalhen> open <module> makes module's content availlable in the main namespace
<youknow365> let client_sock = Unix.socket PF_INET SOCK_STREAM 0 in
<youknow365> connect client_sock (ADDR_INET ((Unix.inet_addr_of_string "127.0.0.1"), 4550))
<youknow365> thats all i have
<youknow365> for unix stuff
<shekmalhen> oh well... gotta go to sleep
shekmalhen has quit ["bêêêêh"]
<youknow365> if anyone in here is a ocaml guru please let me know
_jol_ has joined #ocaml
_jol_ has quit [Read error: 113 (No route to host)]
pango__ is now known as pango
<pango> youknow365: before let client_sock ... you need either ;; or let _ =
smimou has joined #ocaml
Snark has quit ["Leaving"]
mnemonic has joined #ocaml
mnemonic has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
mnemonic has quit [Read error: 104 (Connection reset by peer)]
mnemonic has joined #ocaml
slipstream has quit [Read error: 110 (Connection timed out)]
<oracle1> anyone has debian apt sources.list entries for ocaml 3.09.2 ?
<pango> oracle1: for stable I guess ? Nothing in backports or apt-get.org... You could probably recompile testing version with stable...
mnemonic has quit [Read error: 104 (Connection reset by peer)]
<pango> sudo apt-get build-dep ocaml, apt-get source ocaml, cd ocaml-3.09.2, dpkg-buildpackage -rfakeroot -b -uc, and you should get something like http://concept.free.free.fr/ocaml/3.09-for-sarge/ ... but depending on what you'll using it for, you'll probably have to recompile other libs too...
basti_ has joined #ocaml
ziggurat has quit ["Leaving"]
slipstream has joined #ocaml
_jol_ has joined #ocaml
<_jol_> hello dear camlers,
<basti_> hi
<_jol_> does anyone know why the following isn't valid :
<_jol_> type my_type = {my_attr:int} Lazy.t;;
<_jol_> ?
<pango> try type my_record_type = { my_attr:int } and my_type = my_record_type Lazy.t
<_jol_> indeed, it works. But why isn't the former a valid type declaration ?
<pango> http://caml.inria.fr/pub/docs/manual-ocaml/manual012.html: "There are no type expressions describing (defined) variant types nor record types, since those are always named, i.e. defined before use and referred to by name.". As for the "why", I don't know
<_jol_> ok, i just wondered if it was a known behaviour. thanks for your answers.
<pango> I suppose that any type that can appear in expressions while constructing or deconstructing datastructures must be named (for error reporting, and maybe more)
<basti_> is there some rudimentary http server in ocaml somewhere?
<basti_> thanks :)
<basti_> mm ok i think I'll stick to apache and mod-ocaml... ^^
<smimou> basti_: you can also have a look at ocsigen (ocsigen.org I think)
<basti_> oooo :)
<basti_> this looks nice
* basti_ is doing preresearch for a "make your own homepage using your web browser" thing
<basti_> we got one written in PHP, and it sucks a lot
<_jol_> basti_: you may be interested in this comparison of different frameworks : http://www.demexp.org/en/doku.php?id=web_client_development_framework#comparison_of_ocaml_frameworks
<basti_> ooo youre too kind :)
<basti_> mmm
mpc has joined #ocaml
mpc has quit [Remote closed the connection]
<youknow365> yoooo anyone up ?????
<basti_> nope
<youknow365> basti_: ey man you familiar with this Ocaml ?
<basti_> I'm trying
<basti_> I'm a haskell guy who uses ocaml occasionally for speed and/or lowlevel stuff
<youknow365> do you know anythig yet or are you a beginner ?
<youknow365> i seeeee
<basti_> i know quite a lot, but I won't be able to answer some details
<youknow365> syntax error line 10 .........i dont see anything
<basti_> maybe indent line 11?
<youknow365> umm? can you explain ?
<basti_> put spaces in front of the statement in line 11?
<youknow365> there us no line 11
<basti_> it certainly looks like there'd be one
<youknow365> sorry heres the better formatted version
<basti_> ok
mpc has joined #ocaml
<pango> youknow365: before let client_sock ... you need either ;; or let _ =
<youknow365> can yoo show me
<youknow365> sorry but im barely learning this
<pango> basti_: ocaml is not indentation-sensitive... unless using something like http://people.csail.mit.edu/mikelin/ocaml+twt/
<basti_> pango: mmk.
<basti_> as i said, only sporadically ^^
<youknow365> i write in a iterative style ..........i dont like the functional stuff all to much buut i do like the syntax and shortness of code
<youknow365> i have talked ot mike lin before......amazing man
<smimou> let () = ... is often considered as better style than let _ = ...
<basti_> _ sure sounds like prolog...
<youknow365> why did you put ignore ??
<pango> youknow365: because all your functions return results that you aren't using
<youknow365> pango: im sorru but still not following
<youknow365> so what does the ignore do .......ignore the function ?
<pango> # ignore ;;
<pango> - : 'a -> unit = <fun>
<pango> ignore takes one argument, and does nothing with it
<youknow365> but why use ignores of my socket send ?
<pango> because it returns a result (number of bytes sent, I think), that you aren't using
<youknow365> ahhhh
<youknow365> i didnt know it returns anything
<youknow365> but the function still works right ??
<pango> compiler only give a warning, but the program should work nonetheless, yes
<youknow365> why did you use open Unix ??
<youknow365> i used Unix.
<youknow365> i thought i didnt need it
<pango> because you use several things defined in Unix module without prefixing them with "Unix."
<youknow365> like what ?
_jol_ has quit [".ei mi cliva"]
<pango> Unix.send, Unix.recv, Unix.PF_INET, Unix.SOCK_STREAM, Unix.ADDR_INET...
<youknow365> so if i prefix those i dont need it right ?
<pango> yes
<youknow365> whats better ot do prefix or jus take out the Unix. and just add open Unix ?
<pango> depends on the case
<pango> in this case, you're using the Unix module a lot, and identifiers defined in Unix will probably not clash with other names, so I think it's ok to use open
<pango> datastructure modules (list, array, etc.) often all define the same names (create, get, set, length...) so it's usually not wise to open them
<youknow365> i seeeeeee
<youknow365> ok so .......it worked but do i need these cmo and cmi files to run the program ?
<youknow365> or are those like .o files for C
Carillon_ has joined #ocaml
<youknow365> i mean the same thing
<basti_> cmo is comparable to .o
<pango> cmi is compiled module interface, cmo is compiled module implementation
<basti_> cmi is more like c's .h files
<youknow365> ahhhhh
<youknow365> Fatal error: exception Unix.Unix_error(63, "connect", "")
<youknow365> that happens when i try to run the program
<pango> (bytecode compiled module implementation, to be precise)
<youknow365> connect client_sock (ADDR_INET ((inet_addr_of_string "127.0.0.1"), 4550));
<youknow365> something wrogn with this line ?
<basti_> maybe the exception is that there is noone listening?
<youknow365> ooooo
<youknow365> would it return that error
<youknow365> i jus thougut maybe nothing would happen
<basti_> I'm just doing guesswork
<basti_> ocsigen built -rubs hands-
<youknow365> ok that worked
<youknow365> but i have netcat listening but i see nothing on screeen
<youknow365> netcat -l -p 4550
<basti_> hmm
<youknow365> then i run my ./tcp
<youknow365> and it should send TEEEEEEEST to my netcat
<basti_> maybe the buffer didn't flush?
<basti_> but your program ends doesnt it?
<youknow365> no
gonnet has joined #ocaml
<youknow365> i forgot to add the close sock in there
<basti_> ah
<gonnet> yop
<youknow365> but how would that be a problem ?
<basti_> hmm btw, you're trying to recieve 1024 bytes there?
<youknow365> did you seeth e code ?
<basti_> yea
<basti_> ignore (sock_recv client_sock 1024);
<youknow365> ignore (sock_send client_sock "teeeeeeeeeeeeest");
<basti_> yea, but the recv is right before that
<youknow365> yes
<youknow365> some guy told me to put it there
<basti_> maybe it's blocking?
<pango> I think the program will wait on recv, as basti_ said there's probably a flush missing
<basti_> program finishing or closing the socket should flush
<basti_> (finishing will close the socket too)
<youknow365> what does ignore (sock_recv client_sock 1024); do ?
<basti_> it recieves 1024 bytes of data
<basti_> or if it doesn't, it waits until it does.
<youknow365> it shouldn't recieve anything all im doing is wanting to send that teeeeeest to this socket
<youknow365> so can i jus take those out ?
<basti_> then cut out the recv lines...
<basti_> yea
* gonnet is glad to see we have found a new L3 \o/
<gonnet> (ahem sorry)
<basti_> l3?
<youknow365> guess what
<youknow365> it worked
<youknow365> ok completed first episode of n00b 101
<youknow365> why if i take ignore out it says i need type unit ?
<youknow365> just a warning though right
<basti_> because you're forgetting a number.
<basti_> or, a value
<youknow365> sock_send client_sock "teeeeeeeeeeeeest\n" ;
<basti_> yea that'll return something
<basti_> probably the number of bytes successfully sent
<basti_> or maybe an error
<basti_> so, if you don't ignore that intentionally, the compiler will warn you that something meaningful is gone and won't come back
<youknow365> but basti_ what does Warning S: this expression should have type unit.
<youknow365> what does that mean
descender has quit ["Why has elegance found so little following? Elegance has the disadvantage that hard work is needed to achieve it and a good e]
<basti_> "unit" is the meaningless type
<youknow365> and it ddint return anything ........but i also didnt print any number of bytes sent out
<basti_> the type that has only one value
<basti_> namely ()
<basti_> thats a bit like c's void
<youknow365> ahhhh
<basti_> no it isn't printed, when you don't print it
<youknow365> so what should i put there
<basti_> why would it? ;)
<youknow365> lol
<basti_> "ignore"
<youknow365> i know i know :P
<basti_> :D
<youknow365> how can i print it :P
<basti_> ah ok
<basti_> well, first that depends on what type of value send returns
<basti_> you can look that up in a reference
<youknow365> what do you mean kinf of value ?
<basti_> yes, what "kind"
<youknow365> what kinds are there
<youknow365> ( i will lok up rerfernce )
<basti_> the word "kind" has a very special meaning though - you should say "type"
<basti_> potentially infinitely
<basti_> but there's a few obvious choices.
<basti_> int, for example
<youknow365> ahhh
<youknow365> int cont
<youknow365> char
<youknow365> etc
<youknow365> right ?
<basti_> yea, for example
<basti_> but, in ocaml, there's a very sophisticated type system
<basti_> you can, for example, specify, "an int OR nothing at all"
<youknow365> well can you give me an example ho i would print out a type ?
<basti_> (some kind of N/A or NULL value maybe)
<basti_> you can't print the -type- (not that i know of, might be possible)
<basti_> but you should know the type so that you know how to print it
<youknow365> i mean
<youknow365> how i would declare
<youknow365> sock_send client_sock "teeeeeeeeeeeeest\n" ; as a type unit
<basti_> you can use "ignore", for example.
<youknow365> i know
<youknow365> i am saying if i was going to print it out
<basti_> what you were asking for is: "how can i have .... return (a value of type) unit"
<basti_> okay
<basti_> then we need to know the print command
<youknow365> yes
<youknow365> i knwo :P
<basti_> ^^
<basti_> print will do i think
<basti_> no print_string
<youknow365> yea
<basti_> or print_newline
<basti_> but we need a string for that
<youknow365> yea well let me so dome trial and error stuff
<basti_> print_int would print an int
<basti_> (a rhyme)
<pango> if you add -i to ocamlc or ocamlopt command, it will print inferred types while compiling
<pango> val sock_send : Unix.file_descr -> string -> int
<pango> val sock_recv : Unix.file_descr -> int -> string
<youknow365> i have only been odoing ocaml reallty for the last day and now ........i should prolly look over a few tutorials
<basti_> mm great :)
<youknow365> but it seems alot easier and shorter the nC
<youknow365> and it has a GC
<basti_> so recv really returns an "int"
<pango> # Unix.recv ;;
<pango> - : Unix.file_descr -> string -> int -> int -> Unix.msg_flag list -> int =
<pango> <fun>
<basti_> uhm
<basti_> send
<basti_> sry
<pango> same signature
<basti_> ^^
descender has joined #ocaml
<youknow365> so ok sock_send returns a char or something right ?
<youknow365> anyone here ever use jabber ?
<pango> sock_send returns an int
<youknow365> i meant to say int
<youknow365> well how would i print it out then
<pango> char and ints aren't the same thing ;)
<youknow365> yea yea i know :P
<pango> the easiest way, specially since you know C, would be Printf.printf "%d\n" (sock_send ...)
<youknow365> int are numbers
<youknow365> Printf.printf "%s" sock_send ;
<youknow365> will that work ?
<pango> no, sock_send is a function, it's type is Unix.file_descr -> string -> int, not int
<youknow365> yea
<pango> you could use let result = sock_send ... in Printf.printf "%d\n" result however
<youknow365> i was wondering how so specify the result
<youknow365> do i print it afteri close the socket or before ?
<pango> doesn't matter
<youknow365> so maybe better after words ?
<pango> since the result won't be sent over the socket, but thru stdout
<youknow365> i mean d i declare it before or after whats better
<pango> let ... in ... is the declaration
<youknow365> i know i really havent looked over to much basic string manipulation ........but i thoguht its %s
<pango> ah, you mean in Printf.printf format ? yes, it's %s. It tries to closely mimic C's printf
<youknow365> when wouyld you use %d ??
<pango> you can have a look to printf.mli in ocaml's libs directory
<pango> sock_send returns an int
<youknow365> %d is for int ?
<pango> yes
<youknow365> and %s for string right ?
<pango> printed in decimal format
<pango> %s is for strings
<youknow365> good good ok
<youknow365> let me try this
<youknow365> ooo big question
<youknow365> when do i use ;; or ; 's ?
<pango> ; is used to separate expressions in a sequence
<pango> ;; is used to separate sentences in a module, but %90 of the time it can be inferred and left implicit
jcreigh has joined #ocaml
<youknow365> does that look ok to you
gonnet has left #ocaml []
<pango> won't work
<pango> let result = sock_send in ... will declare a new function called result, that's an alias on sock_send
<youknow365> yea
<pango> what you want is the value of sock_send client_sock "teeeeeeeeeeeeest\n", so you want let result = sock_send client_sock "teeeeeeeeeeeeest\n" ...
<pango> oups, forgot the "in"
<pango> let result = sock_send client_sock "teeeeeeeeeeeeest\n" in ...
<youknow365> ooo
<pango> let in construct stops and the end of the sequence after it, so result scope will continue until the end of your program, and it will just work
<youknow365> i will try to understand whwhat you just said in one moment :P
<pango> in "let v = e in e1; e2", v scope is "e1; e2"
<pango> so you can use it in e2, too
* basti_ now tries ocsigen
<pango> youknow365: btw, you already did this with client_sock, so you shouldn't be surprized ;)
<basti_> mmm ocsigen doesn't seem to find my modules
<basti_> or can't call
mpc has quit []
gn has joined #ocaml
<youknow365> ok cool workd 17 bytes
<youknow365> the C equivalent to this is almost twice as long
<youknow365> sock_recv << what is this for again ?
<basti_> heh. ocaml is pretty terse - you won't notice how terse it really is until you see a more serious example
<basti_> it recieves n bytes from a socket
<youknow365> terse?
<basti_> small
<youknow365> ahhhh
<youknow365> well i am doiing some GTK stuff and this socket thing and yea
<youknow365> in real world everytime i send something over a socket should i do a check to make sure it got sent ?
<youknow365> or is that not needed
mpc has joined #ocaml
<basti_> hmm
<basti_> let's put it like that: you -should-, somehow
<basti_> the trick is: if you didn't send all the data, then something is majorly fucked up anyway, and it'll be ok to crash and burn
<youknow365> so not needed right ?
<basti_> it'll bite you some time
<basti_> but in reality noone ever checks
<basti_> youknow365: a good practice (and good for your practice) would probably be to write a function that at least fails with a half-way sane message in that case
<basti_> like sock_send_check "..."
gn has quit []
mnemonic has joined #ocaml
<mnemonic> hi
<basti_> hi
shawn__ has joined #ocaml
<youknow365> basti_: can you explain for me how to listen on the same port ?
<youknow365> basically on port 4550 i want to send packets and listen for new ones
<basti_> you're aware that listening on a port and recieving packets over an established connection are different things?
<youknow365> yes i do
<youknow365> of course :P
<basti_> so do you want to listen on a port, or recieve incoming packets?
<youknow365> but theres a recv_sock thingright which is for that ?
<youknow365> wellll
<basti_> that's for recieving packets on an already open connection
<youknow365> to recive incoming packets dont you have to be listening
<youknow365> this is for IM
<basti_> no, you can as well recieve packets from a connection you initiated
<youknow365> send im messages on speicifc port recieve im messages on same port
<basti_> well this depends on what you want to achieve...
<youknow365> that would seem to work since i want sending and reciveing of IM to be on same port
<basti_> first, you're sending on an entirely different "source port"
<youknow365> huh?
<basti_> if you send -to- port 1234, you might be sending -from- port 4824
<basti_> usually you don't specify this part
<youknow365> i kinda get you .......
<basti_> you you should learn how TCP and UDP work
<youknow365> 3i will be sending ims to a jabber server on port 4550
<basti_> see, then you'll only need to connect to the server
<basti_> you'll recieve messages over the very same connection
<youknow365> im sorry i used listen in a differ context
<basti_> "listen" is a valid term here, but it describes something else
<basti_> listening is what the server does until you connect
<youknow365> yes
<youknow365> vnc --listen
<youknow365> etc
* basti_ nods
<youknow365> yea so
<basti_> you'll only have to recieve.
<youknow365> i use the recv_sock thing for reciving packets on the same connection right ?
<basti_> yep
<youknow365> but last time i did that it waited
<basti_> yes, it'll wait for a message to come ^^
<youknow365> i need ot be able to send ims and recive them at the same time
<basti_> i agree completely.
<youknow365> anbd the 1024 thing ?
<basti_> 1024 means: wait for 1024 bytes
<youknow365> whats for what .........how amny bytes i am going to be reciving ?
<basti_> that will give a problem unless your message is exactly 1024 bytes long
<youknow365> i have no idea how many bytes could come ?
<basti_> you can ask the OS how many bytes are in the buffer
<basti_> and thus avoid blocking
<basti_> i think, select does this.
<youknow365> i seeeee
<youknow365> select wor kon linux and windows ?
<youknow365> work
<basti_> i think so, yes.
<youknow365> i remmeber gnutls had a problem with select not working the same or something on windows
<basti_> i bet there's a higher level way, too, somewhere
<youknow365> hmmmmmm
<youknow365> where ca n i research this at ?
<basti_> maybe you look at examples?
<youknow365> :)
<youknow365> i dont find too many ocaml examples on the internet
<basti_> i bet, many programs do this kind of stuff
<youknow365> i said internet lol
<basti_> :D
<youknow365> you mean find a C equivalent ?
<basti_> no why. any bet there's an ocaml example that does this stuff
<youknow365> where do you find ocaml examples at ?
<basti_> google?
<youknow365> ok i will search but whats this called ?
<youknow365> after i get these 2 little things done it should be pretty easy
<youknow365> no networking stuff there sadly
<youknow365> so i have to know the exact bytes to recive them right ?
<youknow365> i mean if it says 1024 and it recived 980 would it still recive ?
<basti_> yea, but it will wait for the rest, or until the connection is closed
<youknow365> i dont see how this works
<youknow365> doesnt it have to listen anyways to recive new stuff ?
<basti_> how does it work in C?
<youknow365> never did it in C .........only gtk stuff and math sutff in C intesne computering
<youknow365> first time doing sockets ever
ziggurat has joined #ocaml
<basti_> maybe you look at a C example and try to work from there?
<youknow365> yea but i dont even know a C example or where to it it .......and im not trying to open up gaim ;)
<basti_> how about google "socket examples c" or something?
<youknow365> yea yea doing ;)
<youknow365> im not thaaaaaat lazy ;)
<basti_> i think the favoured way is to make "recv" non-blocking (which you can, somehow) and then look at how many bytes you got
<basti_> thats how just about everybody does it
descender has quit [Read error: 54 (Connection reset by peer)]
<youknow365> what do you mean non blocking
<youknow365> does it block or somethig ?
<basti_> "to block" is "waiting for more input"
<basti_> looks like "broken" if there is no more input
<basti_> you can make it return all the input it got
<basti_> (possibly nothing)
<basti_> and never block at all
<youknow365> is that the best and or fastest way to do it
<youknow365> i dont want ims coming in slow lol
<basti_> do not bother about speed in advance.
<youknow365> i understand but still
descender has joined #ocaml
<basti_> your computer is fast enough to do this.
<basti_> really.
<basti_> we're talking about kilobytes a minute
<pango> the difference is that it will immediately return EAGAIN or EWOULDBLOCK error instead of waiting
<youknow365> pango: you got any ideas on how to do this ?
<basti_> smimou: are you there?
<youknow365> hmmmmm
<pango> youknow365: I think you should open the descriptor with O_NONBLOCK, or use Unix.set_nonblock on existing descriptor
<youknow365> i am asking this guy in a c channel maybe the same idea can be transferred
<youknow365> also dont i have ot do memory allocation stuff for this ?
<basti_> nope you don't
<pango> yes, Unix is a very thin layer on top of C library
<youknow365> when do i have to start doing memory allocation ?
<basti_> you don't.
<basti_> recv will allocate for you.
<youknow365> i seee
<basti_> and ocaml will free when you don't need it anymore
<pango> (or should I just say on top of Unix syscalls ?)
<youknow365> does it do it automatically ?
<youknow365> does this unix socket stuff work if i compile on windows ?
<basti_> I'd think so yes.
<pango> most of the Unix module is implemented on windows to
<pango> s/to/too/
<pango> interestingly enough, set_nonblock isn't
<youknow365> lol
<youknow365> square One :)
<basti_> yes, windows is broken
<youknow365> youknow365: recv returns how many bytes was actually received. what you specify for recv is just the maximum number of bytes to receive
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
<pango> recv(2) manpage gives the behavior of the underlying system call in gory details ;)
<youknow365> soooo what should i do :P
pango_ has quit [SendQ exceeded]
finelemo1 has joined #ocaml
<youknow365> :(
<youknow365> whats a good number of bytes for a maximium im ?
<pango> infinity ;) better not enforce arbitrary limits if you can (however ocaml strings are limited to 16M chars, so it could interfere)
finelemon has quit [Read error: 113 (No route to host)]
<youknow365> 194313 is max bytes
<youknow365> you can send in jabber
jcreigh has joined #ocaml
<youknow365> any idead since i now have a max number of bytes?
<youknow365> no actually around 1 kb is max
<youknow365> grrrrrr
<youknow365> Each allowable portion of a JID (node identifier, domain identifier,
<youknow365> and resource identifier) MUST NOT be more than 1023 bytes in length,
<youknow365> resulting in a maximum total size (including the '@' and '/'
<youknow365> separators) of 3071 bytes.
<youknow365> so i guess 3071 is max bytes
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
<youknow365> hmmmmm
<pango> iirc jabber uses xml, right ? if I were you, I'd investigate xml parsing libs...
ziggurat has quit ["Leaving"]
ziggurat has joined #ocaml
<youknow365> pango: yes but i still need to send and recive them
<youknow365> i am going ot use simply XML
<youknow365> its a very small and fast XML parser
<youknow365> pango: how often do you flush sockets ?
<pango> well, I'm not a network code guru... But you probably need to flush data each time you want to be sure data was really sent
mnemonic has quit ["leaving"]
shining has joined #ocaml
shining has quit [Client Quit]
shining has joined #ocaml
jcreigh has joined #ocaml
ziggurat has quit ["Leaving"]
basti_ has quit ["n8"]
smimou has quit [Read error: 110 (Connection timed out)]
smimou has joined #ocaml
jcreigh has quit ["Cuius rei demonstrationem mirabilem sane detexi. Hanc marginis exiguitas non caperet."]
desc has joined #ocaml
<youknow365> pango: what does flushing do again ?
descender has quit [Nick collision from services.]
desc is now known as descender
descender has quit [Read error: 60 (Operation timed out)]
<youknow365> anyone up
finelemon has joined #ocaml
finelemo1 has quit [Read error: 60 (Operation timed out)]
mpc has quit []