Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
11
Task/Sockets/OCaml/sockets-1.ocaml
Normal file
11
Task/Sockets/OCaml/sockets-1.ocaml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
open Unix
|
||||
|
||||
let init_socket addr port =
|
||||
let inet_addr = (gethostbyname addr).h_addr_list.(0) in
|
||||
let sockaddr = ADDR_INET (inet_addr, port) in
|
||||
let sock = socket PF_INET SOCK_STREAM 0 in
|
||||
connect sock sockaddr;
|
||||
(* convert the file descriptor into high-level channels: *)
|
||||
let outchan = out_channel_of_descr sock in
|
||||
let inchan = in_channel_of_descr sock in
|
||||
(inchan, outchan)
|
||||
4
Task/Sockets/OCaml/sockets-2.ocaml
Normal file
4
Task/Sockets/OCaml/sockets-2.ocaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
let () =
|
||||
let ic, oc = init_socket "localhost" 256 in
|
||||
output_string oc "hello socket world";
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue