File: refuser.ml

package info (click to toggle)
netclient 0.91-10
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,096 kB
  • ctags: 1,539
  • sloc: ml: 8,808; sh: 527; makefile: 203
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);