Skip to content

Instantly share code, notes, and snippets.

View tretre91's full-sized avatar

Trévis Morvany tretre91

  • CEA
  • Saclay
View GitHub Profile
/* inspiré de https://github.com/atwilc3000/sample/blob/master/Bluetooth/rfcomm_server.c */
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <stdbool.h>
#define BUFFER_SIZE 1024
let connect (address: string) port =
let addr = Unix.inet_addr_of_string address in
let inet_addr = Unix.ADDR_INET (addr, port) in
Unix.open_connection inet_addr
let shutdown = Unix.shutdown_connection
let () =
if Array.length Sys.argv < 2 then
Printf.printf "Usage: %s <name>\n" Sys.argv.(0)
type connection = {
inc: in_channel;
outc: out_channel
}
(** Obtient une chaine de caractère de la forme adresse:port à partir d'une sockaddr *)
let string_of_sockaddr = function
| Unix.ADDR_UNIX a -> a
| Unix.ADDR_INET (inet, port) -> Printf.sprintf "%s:%d" (Unix.string_of_inet_addr inet) port
(*
color.ml
Author: Trévis MORVANY
*)
(*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any