File: refuser.ml

package info (click to toggle)
netclient 0.90.4-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,228 kB
  • ctags: 809
  • sloc: ml: 6,369; sh: 495; makefile: 245
file content (11 lines) | stat: -rw-r--r-- 321 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
(* Open a socket, find out the port, and exit the process.
 * The port is guaranteed to refuse a connection for a 
 * moment.
 *)

let s = Unix.socket Unix.PF_INET Unix.SOCK_STREAM 0 in
Unix.listen s 10;
let s_name = Unix.getsockname s in
let Unix.ADDR_INET(inetaddr,port) = s_name in
print_string (string_of_int port);