<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html xmlns:fn="http://www.w3.org/2005/02/xpath-functions"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../../../../doc/otp_doc.css" type="text/css"> <title>Erlang -- gen_sctp</title> </head> <body bgcolor="white" text="#000000" link="#0000ff" vlink="#ff00ff" alink="#ff0000"><div id="container"> <script id="js" type="text/javascript" language="JavaScript" src="../../../../doc/js/flipmenu/flipmenu.js"></script><script id="js2" type="text/javascript" src="../../../../doc/js/erlresolvelinks.js"></script><script language="JavaScript" type="text/javascript"> <!-- function getWinHeight() { var myHeight = 0; if( typeof( window.innerHeight ) == 'number' ) { //Non-IE myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in 'standards compliant mode' myHeight = document.documentElement.clientHeight; } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { //IE 4 compatible myHeight = document.body.clientHeight; } return myHeight; } function setscrollpos() { var objf=document.getElementById('loadscrollpos'); document.getElementById("leftnav").scrollTop = objf.offsetTop - getWinHeight()/2; } function addEvent(obj, evType, fn){ if (obj.addEventListener){ obj.addEventListener(evType, fn, true); return true; } else if (obj.attachEvent){ var r = obj.attachEvent("on"+evType, fn); return r; } else { return false; } } addEvent(window, 'load', setscrollpos); //--></script><div id="leftnav"><div class="innertube"> <img alt="Erlang logo" src="../../../../doc/erlang-logo.png"><br><small><a href="index.html">Reference Manual</a><br><a href="release_notes.html">Release Notes</a><br><a href="../pdf/kernel-2.15.3.pdf">PDF</a><br><a href="../../../../doc/index.html">Top</a></small><p><strong>Kernel</strong><br><strong>Reference Manual</strong><br><small>Version 2.15.3</small></p> <br><a href="javascript:openAllFlips()">Expand All</a><br><a href="javascript:closeAllFlips()">Contract All</a><p><small><strong>Table of Contents</strong></small></p> <ul class="flipMenu"> <li title="kernel (App)"><a href="kernel_app.html">kernel (App) </a></li> <li id="no" title="application " expanded="false">application<ul> <li><a href="application.html"> Top of manual page </a></li> <li title="get_all_env-0"><a href="application.html#get_all_env-0">get_all_env/0</a></li> <li title="get_all_env-1"><a href="application.html#get_all_env-1">get_all_env/1</a></li> <li title="get_all_key-0"><a href="application.html#get_all_key-0">get_all_key/0</a></li> <li title="get_all_key-1"><a href="application.html#get_all_key-1">get_all_key/1</a></li> <li title="get_application-0"><a href="application.html#get_application-0">get_application/0</a></li> <li title="get_application-1"><a href="application.html#get_application-1">get_application/1</a></li> <li title="get_env-1"><a href="application.html#get_env-1">get_env/1</a></li> <li title="get_env-2"><a href="application.html#get_env-2">get_env/2</a></li> <li title="get_key-1"><a href="application.html#get_key-1">get_key/1</a></li> <li title="get_key-2"><a href="application.html#get_key-2">get_key/2</a></li> <li title="load-1"><a href="application.html#load-1">load/1</a></li> <li title="load-2"><a href="application.html#load-2">load/2</a></li> <li title="loaded_applications-0"><a href="application.html#loaded_applications-0">loaded_applications/0</a></li> <li title="permit-2"><a href="application.html#permit-2">permit/2</a></li> <li title="set_env-3"><a href="application.html#set_env-3">set_env/3</a></li> <li title="set_env-4"><a href="application.html#set_env-4">set_env/4</a></li> <li title="start-1"><a href="application.html#start-1">start/1</a></li> <li title="start-2"><a href="application.html#start-2">start/2</a></li> <li title="start_type-0"><a href="application.html#start_type-0">start_type/0</a></li> <li title="stop-1"><a href="application.html#stop-1">stop/1</a></li> <li title="takeover-2"><a href="application.html#takeover-2">takeover/2</a></li> <li title="unload-1"><a href="application.html#unload-1">unload/1</a></li> <li title="unset_env-2"><a href="application.html#unset_env-2">unset_env/2</a></li> <li title="unset_env-3"><a href="application.html#unset_env-3">unset_env/3</a></li> <li title="which_applications-0"><a href="application.html#which_applications-0">which_applications/0</a></li> <li title="which_applications-1"><a href="application.html#which_applications-1">which_applications/1</a></li> <li title="Module:start-2"><a href="application.html#Module:start-2">Module:start/2</a></li> <li title="Module:start_phase-3"><a href="application.html#Module:start_phase-3">Module:start_phase/3</a></li> <li title="Module:prep_stop-1"><a href="application.html#Module:prep_stop-1">Module:prep_stop/1</a></li> <li title="Module:stop-1"><a href="application.html#Module:stop-1">Module:stop/1</a></li> <li title="Module:config_change-3"><a href="application.html#Module:config_change-3">Module:config_change/3</a></li> </ul> </li> <li id="no" title="auth " expanded="false">auth<ul> <li><a href="auth.html"> Top of manual page </a></li> <li title="is_auth-1"><a href="auth.html#is_auth-1">is_auth/1</a></li> <li title="cookie-0"><a href="auth.html#cookie-0">cookie/0</a></li> <li title="cookie-1"><a href="auth.html#cookie-1">cookie/1</a></li> <li title="node_cookie-1"><a href="auth.html#node_cookie-1">node_cookie/1</a></li> <li title="node_cookie-2"><a href="auth.html#node_cookie-2">node_cookie/2</a></li> </ul> </li> <li id="no" title="code " expanded="false">code<ul> <li><a href="code.html"> Top of manual page </a></li> <li title="set_path-1"><a href="code.html#set_path-1">set_path/1</a></li> <li title="get_path-0"><a href="code.html#get_path-0">get_path/0</a></li> <li title="add_path-1"><a href="code.html#add_path-1">add_path/1</a></li> <li title="add_pathz-1"><a href="code.html#add_pathz-1">add_pathz/1</a></li> <li title="add_patha-1"><a href="code.html#add_patha-1">add_patha/1</a></li> <li title="add_paths-1"><a href="code.html#add_paths-1">add_paths/1</a></li> <li title="add_pathsz-1"><a href="code.html#add_pathsz-1">add_pathsz/1</a></li> <li title="add_pathsa-1"><a href="code.html#add_pathsa-1">add_pathsa/1</a></li> <li title="del_path-1"><a href="code.html#del_path-1">del_path/1</a></li> <li title="replace_path-2"><a href="code.html#replace_path-2">replace_path/2</a></li> <li title="load_file-1"><a href="code.html#load_file-1">load_file/1</a></li> <li title="load_abs-1"><a href="code.html#load_abs-1">load_abs/1</a></li> <li title="ensure_loaded-1"><a href="code.html#ensure_loaded-1">ensure_loaded/1</a></li> <li title="load_binary-3"><a href="code.html#load_binary-3">load_binary/3</a></li> <li title="delete-1"><a href="code.html#delete-1">delete/1</a></li> <li title="purge-1"><a href="code.html#purge-1">purge/1</a></li> <li title="soft_purge-1"><a href="code.html#soft_purge-1">soft_purge/1</a></li> <li title="is_loaded-1"><a href="code.html#is_loaded-1">is_loaded/1</a></li> <li title="all_loaded-0"><a href="code.html#all_loaded-0">all_loaded/0</a></li> <li title="which-1"><a href="code.html#which-1">which/1</a></li> <li title="get_object_code-1"><a href="code.html#get_object_code-1">get_object_code/1</a></li> <li title="root_dir-0"><a href="code.html#root_dir-0">root_dir/0</a></li> <li title="lib_dir-0"><a href="code.html#lib_dir-0">lib_dir/0</a></li> <li title="lib_dir-1"><a href="code.html#lib_dir-1">lib_dir/1</a></li> <li title="lib_dir-2"><a href="code.html#lib_dir-2">lib_dir/2</a></li> <li title="compiler_dir-0"><a href="code.html#compiler_dir-0">compiler_dir/0</a></li> <li title="priv_dir-1"><a href="code.html#priv_dir-1">priv_dir/1</a></li> <li title="objfile_extension-0"><a href="code.html#objfile_extension-0">objfile_extension/0</a></li> <li title="stick_dir-1"><a href="code.html#stick_dir-1">stick_dir/1</a></li> <li title="unstick_dir-1"><a href="code.html#unstick_dir-1">unstick_dir/1</a></li> <li title="is_sticky-1"><a href="code.html#is_sticky-1">is_sticky/1</a></li> <li title="rehash-0"><a href="code.html#rehash-0">rehash/0</a></li> <li title="where_is_file-1"><a href="code.html#where_is_file-1">where_is_file/1</a></li> <li title="clash-0"><a href="code.html#clash-0">clash/0</a></li> <li title="is_module_native-1"><a href="code.html#is_module_native-1">is_module_native/1</a></li> </ul> </li> <li id="no" title="disk_log " expanded="false">disk_log<ul> <li><a href="disk_log.html"> Top of manual page </a></li> <li title="accessible_logs-0"><a href="disk_log.html#accessible_logs-0">accessible_logs/0</a></li> <li title="alog-2"><a href="disk_log.html#alog-2">alog/2</a></li> <li title="balog-2"><a href="disk_log.html#balog-2">balog/2</a></li> <li title="alog_terms-2"><a href="disk_log.html#alog_terms-2">alog_terms/2</a></li> <li title="balog_terms-2"><a href="disk_log.html#balog_terms-2">balog_terms/2</a></li> <li title="block-1"><a href="disk_log.html#block-1">block/1</a></li> <li title="block-2"><a href="disk_log.html#block-2">block/2</a></li> <li title="change_header-2"><a href="disk_log.html#change_header-2">change_header/2</a></li> <li title="change_notify-3"><a href="disk_log.html#change_notify-3">change_notify/3</a></li> <li title="change_size-2"><a href="disk_log.html#change_size-2">change_size/2</a></li> <li title="chunk-2"><a href="disk_log.html#chunk-2">chunk/2</a></li> <li title="chunk-3"><a href="disk_log.html#chunk-3">chunk/3</a></li> <li title="bchunk-2"><a href="disk_log.html#bchunk-2">bchunk/2</a></li> <li title="bchunk-3"><a href="disk_log.html#bchunk-3">bchunk/3</a></li> <li title="chunk_info-1"><a href="disk_log.html#chunk_info-1">chunk_info/1</a></li> <li title="chunk_step-3"><a href="disk_log.html#chunk_step-3">chunk_step/3</a></li> <li title="close-1"><a href="disk_log.html#close-1">close/1</a></li> <li title="format_error-1"><a href="disk_log.html#format_error-1">format_error/1</a></li> <li title="inc_wrap_file-1"><a href="disk_log.html#inc_wrap_file-1">inc_wrap_file/1</a></li> <li title="info-1"><a href="disk_log.html#info-1">info/1</a></li> <li title="lclose-1"><a href="disk_log.html#lclose-1">lclose/1</a></li> <li title="lclose-2"><a href="disk_log.html#lclose-2">lclose/2</a></li> <li title="log-2"><a href="disk_log.html#log-2">log/2</a></li> <li title="blog-2"><a href="disk_log.html#blog-2">blog/2</a></li> <li title="log_terms-2"><a href="disk_log.html#log_terms-2">log_terms/2</a></li> <li title="blog_terms-2"><a href="disk_log.html#blog_terms-2">blog_terms/2</a></li> <li title="open-1"><a href="disk_log.html#open-1">open/1</a></li> <li title="pid2name-1"><a href="disk_log.html#pid2name-1">pid2name/1</a></li> <li title="reopen-2"><a href="disk_log.html#reopen-2">reopen/2</a></li> <li title="reopen-3"><a href="disk_log.html#reopen-3">reopen/3</a></li> <li title="breopen-3"><a href="disk_log.html#breopen-3">breopen/3</a></li> <li title="sync-1"><a href="disk_log.html#sync-1">sync/1</a></li> <li title="truncate-1"><a href="disk_log.html#truncate-1">truncate/1</a></li> <li title="truncate-2"><a href="disk_log.html#truncate-2">truncate/2</a></li> <li title="btruncate-2"><a href="disk_log.html#btruncate-2">btruncate/2</a></li> <li title="unblock-1"><a href="disk_log.html#unblock-1">unblock/1</a></li> </ul> </li> <li id="no" title="erl_boot_server " expanded="false">erl_boot_server<ul> <li><a href="erl_boot_server.html"> Top of manual page </a></li> <li title="start-1"><a href="erl_boot_server.html#start-1">start/1</a></li> <li title="start_link-1"><a href="erl_boot_server.html#start_link-1">start_link/1</a></li> <li title="add_slave-1"><a href="erl_boot_server.html#add_slave-1">add_slave/1</a></li> <li title="delete_slave-1"><a href="erl_boot_server.html#delete_slave-1">delete_slave/1</a></li> <li title="which_slaves-0"><a href="erl_boot_server.html#which_slaves-0">which_slaves/0</a></li> </ul> </li> <li id="no" title="erl_ddll " expanded="false">erl_ddll<ul> <li><a href="erl_ddll.html"> Top of manual page </a></li> <li title="demonitor-1"><a href="erl_ddll.html#demonitor-1">demonitor/1</a></li> <li title="info-0"><a href="erl_ddll.html#info-0">info/0</a></li> <li title="info-1"><a href="erl_ddll.html#info-1">info/1</a></li> <li title="info-2"><a href="erl_ddll.html#info-2">info/2</a></li> <li title="load-2"><a href="erl_ddll.html#load-2">load/2</a></li> <li title="load_driver-2"><a href="erl_ddll.html#load_driver-2">load_driver/2</a></li> <li title="monitor-2"><a href="erl_ddll.html#monitor-2">monitor/2</a></li> <li title="reload-2"><a href="erl_ddll.html#reload-2">reload/2</a></li> <li title="reload_driver-2"><a href="erl_ddll.html#reload_driver-2">reload_driver/2</a></li> <li title="try_load-3"><a href="erl_ddll.html#try_load-3">try_load/3</a></li> <li title="try_unload-2"><a href="erl_ddll.html#try_unload-2">try_unload/2</a></li> <li title="unload-1"><a href="erl_ddll.html#unload-1">unload/1</a></li> <li title="unload_driver-1"><a href="erl_ddll.html#unload_driver-1">unload_driver/1</a></li> <li title="loaded_drivers-0"><a href="erl_ddll.html#loaded_drivers-0">loaded_drivers/0</a></li> <li title="format_error-1"><a href="erl_ddll.html#format_error-1">format_error/1</a></li> </ul> </li> <li title="erl_prim_loader"><a href="erl_prim_loader.html">erl_prim_loader</a></li> <li title="erlang"><a href="erlang.html">erlang</a></li> <li id="no" title="error_handler " expanded="false">error_handler<ul> <li><a href="error_handler.html"> Top of manual page </a></li> <li title="undefined_function-3"><a href="error_handler.html#undefined_function-3">undefined_function/3</a></li> <li title="undefined_lambda-3"><a href="error_handler.html#undefined_lambda-3">undefined_lambda/3</a></li> </ul> </li> <li id="no" title="error_logger " expanded="false">error_logger<ul> <li><a href="error_logger.html"> Top of manual page </a></li> <li title="error_msg-1"><a href="error_logger.html#error_msg-1">error_msg/1</a></li> <li title="error_msg-2"><a href="error_logger.html#error_msg-2">error_msg/2</a></li> <li title="format-2"><a href="error_logger.html#format-2">format/2</a></li> <li title="error_report-1"><a href="error_logger.html#error_report-1">error_report/1</a></li> <li title="error_report-2"><a href="error_logger.html#error_report-2">error_report/2</a></li> <li title="warning_map-0"><a href="error_logger.html#warning_map-0">warning_map/0</a></li> <li title="warning_msg-1"><a href="error_logger.html#warning_msg-1">warning_msg/1</a></li> <li title="warning_msg-2"><a href="error_logger.html#warning_msg-2">warning_msg/2</a></li> <li title="warning_report-1"><a href="error_logger.html#warning_report-1">warning_report/1</a></li> <li title="warning_report-2"><a href="error_logger.html#warning_report-2">warning_report/2</a></li> <li title="info_msg-1"><a href="error_logger.html#info_msg-1">info_msg/1</a></li> <li title="info_msg-2"><a href="error_logger.html#info_msg-2">info_msg/2</a></li> <li title="info_report-1"><a href="error_logger.html#info_report-1">info_report/1</a></li> <li title="info_report-2"><a href="error_logger.html#info_report-2">info_report/2</a></li> <li title="add_report_handler-1"><a href="error_logger.html#add_report_handler-1">add_report_handler/1</a></li> <li title="add_report_handler-2"><a href="error_logger.html#add_report_handler-2">add_report_handler/2</a></li> <li title="delete_report_handler-1"><a href="error_logger.html#delete_report_handler-1">delete_report_handler/1</a></li> <li title="tty-1"><a href="error_logger.html#tty-1">tty/1</a></li> <li title="logfile-1"><a href="error_logger.html#logfile-1">logfile/1</a></li> </ul> </li> <li id="no" title="file " expanded="false">file<ul> <li><a href="file.html"> Top of manual page </a></li> <li title="advise-4"><a href="file.html#advise-4">advise/4</a></li> <li title="change_group-2"><a href="file.html#change_group-2">change_group/2</a></li> <li title="change_mode-2"><a href="file.html#change_mode-2">change_mode/2</a></li> <li title="change_owner-2"><a href="file.html#change_owner-2">change_owner/2</a></li> <li title="change_owner-3"><a href="file.html#change_owner-3">change_owner/3</a></li> <li title="change_time-2"><a href="file.html#change_time-2">change_time/2</a></li> <li title="change_time-3"><a href="file.html#change_time-3">change_time/3</a></li> <li title="close-1"><a href="file.html#close-1">close/1</a></li> <li title="consult-1"><a href="file.html#consult-1">consult/1</a></li> <li title="copy-2"><a href="file.html#copy-2">copy/2</a></li> <li title="copy-3"><a href="file.html#copy-3">copy/3</a></li> <li title="del_dir-1"><a href="file.html#del_dir-1">del_dir/1</a></li> <li title="delete-1"><a href="file.html#delete-1">delete/1</a></li> <li title="eval-1"><a href="file.html#eval-1">eval/1</a></li> <li title="eval-2"><a href="file.html#eval-2">eval/2</a></li> <li title="file_info-1"><a href="file.html#file_info-1">file_info/1</a></li> <li title="format_error-1"><a href="file.html#format_error-1">format_error/1</a></li> <li title="get_cwd-0"><a href="file.html#get_cwd-0">get_cwd/0</a></li> <li title="get_cwd-1"><a href="file.html#get_cwd-1">get_cwd/1</a></li> <li title="list_dir-1"><a href="file.html#list_dir-1">list_dir/1</a></li> <li title="make_dir-1"><a href="file.html#make_dir-1">make_dir/1</a></li> <li title="make_link-2"><a href="file.html#make_link-2">make_link/2</a></li> <li title="make_symlink-2"><a href="file.html#make_symlink-2">make_symlink/2</a></li> <li title="native_name_encoding-0"><a href="file.html#native_name_encoding-0">native_name_encoding/0</a></li> <li title="open-2"><a href="file.html#open-2">open/2</a></li> <li title="path_consult-2"><a href="file.html#path_consult-2">path_consult/2</a></li> <li title="path_eval-2"><a href="file.html#path_eval-2">path_eval/2</a></li> <li title="path_open-3"><a href="file.html#path_open-3">path_open/3</a></li> <li title="path_script-2"><a href="file.html#path_script-2">path_script/2</a></li> <li title="path_script-3"><a href="file.html#path_script-3">path_script/3</a></li> <li title="pid2name-1"><a href="file.html#pid2name-1">pid2name/1</a></li> <li title="position-2"><a href="file.html#position-2">position/2</a></li> <li title="pread-2"><a href="file.html#pread-2">pread/2</a></li> <li title="pread-3"><a href="file.html#pread-3">pread/3</a></li> <li title="pwrite-2"><a href="file.html#pwrite-2">pwrite/2</a></li> <li title="pwrite-3"><a href="file.html#pwrite-3">pwrite/3</a></li> <li title="read-2"><a href="file.html#read-2">read/2</a></li> <li title="read_file-1"><a href="file.html#read_file-1">read_file/1</a></li> <li title="read_file_info-1"><a href="file.html#read_file_info-1">read_file_info/1</a></li> <li title="read_file_info-2"><a href="file.html#read_file_info-2">read_file_info/2</a></li> <li title="read_line-1"><a href="file.html#read_line-1">read_line/1</a></li> <li title="read_link-1"><a href="file.html#read_link-1">read_link/1</a></li> <li title="read_link_info-1"><a href="file.html#read_link_info-1">read_link_info/1</a></li> <li title="read_link_info-2"><a href="file.html#read_link_info-2">read_link_info/2</a></li> <li title="rename-2"><a href="file.html#rename-2">rename/2</a></li> <li title="script-1"><a href="file.html#script-1">script/1</a></li> <li title="script-2"><a href="file.html#script-2">script/2</a></li> <li title="set_cwd-1"><a href="file.html#set_cwd-1">set_cwd/1</a></li> <li title="sync-1"><a href="file.html#sync-1">sync/1</a></li> <li title="datasync-1"><a href="file.html#datasync-1">datasync/1</a></li> <li title="truncate-1"><a href="file.html#truncate-1">truncate/1</a></li> <li title="sendfile-2"><a href="file.html#sendfile-2">sendfile/2</a></li> <li title="sendfile-5"><a href="file.html#sendfile-5">sendfile/5</a></li> <li title="write-2"><a href="file.html#write-2">write/2</a></li> <li title="write_file-2"><a href="file.html#write_file-2">write_file/2</a></li> <li title="write_file-3"><a href="file.html#write_file-3">write_file/3</a></li> <li title="write_file_info-2"><a href="file.html#write_file_info-2">write_file_info/2</a></li> <li title="write_file_info-3"><a href="file.html#write_file_info-3">write_file_info/3</a></li> </ul> </li> <li id="no" title="gen_tcp " expanded="false">gen_tcp<ul> <li><a href="gen_tcp.html"> Top of manual page </a></li> <li title="connect-3"><a href="gen_tcp.html#connect-3">connect/3</a></li> <li title="connect-4"><a href="gen_tcp.html#connect-4">connect/4</a></li> <li title="listen-2"><a href="gen_tcp.html#listen-2">listen/2</a></li> <li title="accept-1"><a href="gen_tcp.html#accept-1">accept/1</a></li> <li title="accept-2"><a href="gen_tcp.html#accept-2">accept/2</a></li> <li title="send-2"><a href="gen_tcp.html#send-2">send/2</a></li> <li title="recv-2"><a href="gen_tcp.html#recv-2">recv/2</a></li> <li title="recv-3"><a href="gen_tcp.html#recv-3">recv/3</a></li> <li title="controlling_process-2"><a href="gen_tcp.html#controlling_process-2">controlling_process/2</a></li> <li title="close-1"><a href="gen_tcp.html#close-1">close/1</a></li> <li title="shutdown-2"><a href="gen_tcp.html#shutdown-2">shutdown/2</a></li> </ul> </li> <li id="no" title="gen_udp " expanded="false">gen_udp<ul> <li><a href="gen_udp.html"> Top of manual page </a></li> <li title="open-1"><a href="gen_udp.html#open-1">open/1</a></li> <li title="open-2"><a href="gen_udp.html#open-2">open/2</a></li> <li title="send-4"><a href="gen_udp.html#send-4">send/4</a></li> <li title="recv-2"><a href="gen_udp.html#recv-2">recv/2</a></li> <li title="recv-3"><a href="gen_udp.html#recv-3">recv/3</a></li> <li title="controlling_process-2"><a href="gen_udp.html#controlling_process-2">controlling_process/2</a></li> <li title="close-1"><a href="gen_udp.html#close-1">close/1</a></li> </ul> </li> <li id="loadscrollpos" title="gen_sctp " expanded="true">gen_sctp<ul> <li><a href="gen_sctp.html"> Top of manual page </a></li> <li title="abort-2"><a href="gen_sctp.html#abort-2">abort/2</a></li> <li title="close-1"><a href="gen_sctp.html#close-1">close/1</a></li> <li title="connect-4"><a href="gen_sctp.html#connect-4">connect/4</a></li> <li title="connect-5"><a href="gen_sctp.html#connect-5">connect/5</a></li> <li title="connect_init-4"><a href="gen_sctp.html#connect_init-4">connect_init/4</a></li> <li title="connect_init-5"><a href="gen_sctp.html#connect_init-5">connect_init/5</a></li> <li title="controlling_process-2"><a href="gen_sctp.html#controlling_process-2">controlling_process/2</a></li> <li title="eof-2"><a href="gen_sctp.html#eof-2">eof/2</a></li> <li title="listen-2"><a href="gen_sctp.html#listen-2">listen/2</a></li> <li title="open-0"><a href="gen_sctp.html#open-0">open/0</a></li> <li title="open-1"><a href="gen_sctp.html#open-1">open/1</a></li> <li title="open-2"><a href="gen_sctp.html#open-2">open/2</a></li> <li title="peeloff-2"><a href="gen_sctp.html#peeloff-2">peeloff/2</a></li> <li title="recv-1"><a href="gen_sctp.html#recv-1">recv/1</a></li> <li title="recv-2"><a href="gen_sctp.html#recv-2">recv/2</a></li> <li title="send-3"><a href="gen_sctp.html#send-3">send/3</a></li> <li title="send-4"><a href="gen_sctp.html#send-4">send/4</a></li> <li title="error_string-1"><a href="gen_sctp.html#error_string-1">error_string/1</a></li> </ul> </li> <li id="no" title="global " expanded="false">global<ul> <li><a href="global.html"> Top of manual page </a></li> <li title="del_lock-1"><a href="global.html#del_lock-1">del_lock/1</a></li> <li title="del_lock-2"><a href="global.html#del_lock-2">del_lock/2</a></li> <li title="notify_all_name-3"><a href="global.html#notify_all_name-3">notify_all_name/3</a></li> <li title="random_exit_name-3"><a href="global.html#random_exit_name-3">random_exit_name/3</a></li> <li title="random_notify_name-3"><a href="global.html#random_notify_name-3">random_notify_name/3</a></li> <li title="register_name-2"><a href="global.html#register_name-2">register_name/2</a></li> <li title="register_name-3"><a href="global.html#register_name-3">register_name/3</a></li> <li title="registered_names-0"><a href="global.html#registered_names-0">registered_names/0</a></li> <li title="re_register_name-2"><a href="global.html#re_register_name-2">re_register_name/2</a></li> <li title="re_register_name-3"><a href="global.html#re_register_name-3">re_register_name/3</a></li> <li title="send-2"><a href="global.html#send-2">send/2</a></li> <li title="set_lock-1"><a href="global.html#set_lock-1">set_lock/1</a></li> <li title="set_lock-2"><a href="global.html#set_lock-2">set_lock/2</a></li> <li title="set_lock-3"><a href="global.html#set_lock-3">set_lock/3</a></li> <li title="sync-0"><a href="global.html#sync-0">sync/0</a></li> <li title="trans-2"><a href="global.html#trans-2">trans/2</a></li> <li title="trans-3"><a href="global.html#trans-3">trans/3</a></li> <li title="trans-4"><a href="global.html#trans-4">trans/4</a></li> <li title="unregister_name-1"><a href="global.html#unregister_name-1">unregister_name/1</a></li> <li title="whereis_name-1"><a href="global.html#whereis_name-1">whereis_name/1</a></li> </ul> </li> <li id="no" title="global_group " expanded="false">global_group<ul> <li><a href="global_group.html"> Top of manual page </a></li> <li title="global_groups-0"><a href="global_group.html#global_groups-0">global_groups/0</a></li> <li title="info-0"><a href="global_group.html#info-0">info/0</a></li> <li title="monitor_nodes-1"><a href="global_group.html#monitor_nodes-1">monitor_nodes/1</a></li> <li title="own_nodes-0"><a href="global_group.html#own_nodes-0">own_nodes/0</a></li> <li title="registered_names-1"><a href="global_group.html#registered_names-1">registered_names/1</a></li> <li title="send-2"><a href="global_group.html#send-2">send/2</a></li> <li title="send-3"><a href="global_group.html#send-3">send/3</a></li> <li title="sync-0"><a href="global_group.html#sync-0">sync/0</a></li> <li title="whereis_name-1"><a href="global_group.html#whereis_name-1">whereis_name/1</a></li> <li title="whereis_name-2"><a href="global_group.html#whereis_name-2">whereis_name/2</a></li> </ul> </li> <li id="no" title="heart " expanded="false">heart<ul> <li><a href="heart.html"> Top of manual page </a></li> <li title="set_cmd-1"><a href="heart.html#set_cmd-1">set_cmd/1</a></li> <li title="clear_cmd-0"><a href="heart.html#clear_cmd-0">clear_cmd/0</a></li> <li title="get_cmd-0"><a href="heart.html#get_cmd-0">get_cmd/0</a></li> </ul> </li> <li id="no" title="inet " expanded="false">inet<ul> <li><a href="inet.html"> Top of manual page </a></li> <li title="close-1"><a href="inet.html#close-1">close/1</a></li> <li title="get_rc-0"><a href="inet.html#get_rc-0">get_rc/0</a></li> <li title="format_error-1"><a href="inet.html#format_error-1">format_error/1</a></li> <li title="getaddr-2"><a href="inet.html#getaddr-2">getaddr/2</a></li> <li title="getaddrs-2"><a href="inet.html#getaddrs-2">getaddrs/2</a></li> <li title="gethostbyaddr-1"><a href="inet.html#gethostbyaddr-1">gethostbyaddr/1</a></li> <li title="gethostbyname-1"><a href="inet.html#gethostbyname-1">gethostbyname/1</a></li> <li title="gethostbyname-2"><a href="inet.html#gethostbyname-2">gethostbyname/2</a></li> <li title="gethostname-0"><a href="inet.html#gethostname-0">gethostname/0</a></li> <li title="getifaddrs-0"><a href="inet.html#getifaddrs-0">getifaddrs/0</a></li> <li title="getopts-2"><a href="inet.html#getopts-2">getopts/2</a></li> <li title="getstat-1"><a href="inet.html#getstat-1">getstat/1</a></li> <li title="getstat-2"><a href="inet.html#getstat-2">getstat/2</a></li> <li title="peername-1"><a href="inet.html#peername-1">peername/1</a></li> <li title="port-1"><a href="inet.html#port-1">port/1</a></li> <li title="sockname-1"><a href="inet.html#sockname-1">sockname/1</a></li> <li title="setopts-2"><a href="inet.html#setopts-2">setopts/2</a></li> </ul> </li> <li id="no" title="inet_res " expanded="false">inet_res<ul> <li><a href="inet_res.html"> Top of manual page </a></li> <li title="getbyname-2"><a href="inet_res.html#getbyname-2">getbyname/2</a></li> <li title="getbyname-3"><a href="inet_res.html#getbyname-3">getbyname/3</a></li> <li title="gethostbyaddr-1"><a href="inet_res.html#gethostbyaddr-1">gethostbyaddr/1</a></li> <li title="gethostbyaddr-2"><a href="inet_res.html#gethostbyaddr-2">gethostbyaddr/2</a></li> <li title="gethostbyname-1"><a href="inet_res.html#gethostbyname-1">gethostbyname/1</a></li> <li title="gethostbyname-2"><a href="inet_res.html#gethostbyname-2">gethostbyname/2</a></li> <li title="gethostbyname-3"><a href="inet_res.html#gethostbyname-3">gethostbyname/3</a></li> <li title="lookup-3"><a href="inet_res.html#lookup-3">lookup/3</a></li> <li title="lookup-4"><a href="inet_res.html#lookup-4">lookup/4</a></li> <li title="lookup-5"><a href="inet_res.html#lookup-5">lookup/5</a></li> <li title="resolve-3"><a href="inet_res.html#resolve-3">resolve/3</a></li> <li title="resolve-4"><a href="inet_res.html#resolve-4">resolve/4</a></li> <li title="resolve-5"><a href="inet_res.html#resolve-5">resolve/5</a></li> <li title="nslookup-3"><a href="inet_res.html#nslookup-3">nslookup/3</a></li> <li title="nslookup-4"><a href="inet_res.html#nslookup-4">nslookup/4</a></li> <li title="nnslookup-4"><a href="inet_res.html#nnslookup-4">nnslookup/4</a></li> <li title="nnslookup-5"><a href="inet_res.html#nnslookup-5">nnslookup/5</a></li> </ul> </li> <li title="init"><a href="init.html">init</a></li> <li id="no" title="net_adm " expanded="false">net_adm<ul> <li><a href="net_adm.html"> Top of manual page </a></li> <li title="dns_hostname-1"><a href="net_adm.html#dns_hostname-1">dns_hostname/1</a></li> <li title="host_file-0"><a href="net_adm.html#host_file-0">host_file/0</a></li> <li title="localhost-0"><a href="net_adm.html#localhost-0">localhost/0</a></li> <li title="names-0"><a href="net_adm.html#names-0">names/0</a></li> <li title="names-1"><a href="net_adm.html#names-1">names/1</a></li> <li title="ping-1"><a href="net_adm.html#ping-1">ping/1</a></li> <li title="world-0"><a href="net_adm.html#world-0">world/0</a></li> <li title="world-1"><a href="net_adm.html#world-1">world/1</a></li> <li title="world_list-1"><a href="net_adm.html#world_list-1">world_list/1</a></li> <li title="world_list-2"><a href="net_adm.html#world_list-2">world_list/2</a></li> </ul> </li> <li id="no" title="net_kernel " expanded="false">net_kernel<ul> <li><a href="net_kernel.html"> Top of manual page </a></li> <li title="allow-1"><a href="net_kernel.html#allow-1">allow/1</a></li> <li title="connect_node-1"><a href="net_kernel.html#connect_node-1">connect_node/1</a></li> <li title="monitor_nodes-1"><a href="net_kernel.html#monitor_nodes-1">monitor_nodes/1</a></li> <li title="monitor_nodes-2"><a href="net_kernel.html#monitor_nodes-2">monitor_nodes/2</a></li> <li title="get_net_ticktime-0"><a href="net_kernel.html#get_net_ticktime-0">get_net_ticktime/0</a></li> <li title="set_net_ticktime-1"><a href="net_kernel.html#set_net_ticktime-1">set_net_ticktime/1</a></li> <li title="set_net_ticktime-2"><a href="net_kernel.html#set_net_ticktime-2">set_net_ticktime/2</a></li> <li title="start-1"><a href="net_kernel.html#start-1">start/1</a></li> <li title="start-1"><a href="net_kernel.html#start-1">start/1</a></li> <li title="start-1"><a href="net_kernel.html#start-1">start/1</a></li> <li title="stop-0"><a href="net_kernel.html#stop-0">stop/0</a></li> </ul> </li> <li id="no" title="os " expanded="false">os<ul> <li><a href="os.html"> Top of manual page </a></li> <li title="cmd-1"><a href="os.html#cmd-1">cmd/1</a></li> <li title="find_executable-1"><a href="os.html#find_executable-1">find_executable/1</a></li> <li title="find_executable-2"><a href="os.html#find_executable-2">find_executable/2</a></li> <li title="getenv-0"><a href="os.html#getenv-0">getenv/0</a></li> <li title="getenv-1"><a href="os.html#getenv-1">getenv/1</a></li> <li title="getpid-0"><a href="os.html#getpid-0">getpid/0</a></li> <li title="putenv-2"><a href="os.html#putenv-2">putenv/2</a></li> <li title="timestamp-0"><a href="os.html#timestamp-0">timestamp/0</a></li> <li title="type-0"><a href="os.html#type-0">type/0</a></li> <li title="version-0"><a href="os.html#version-0">version/0</a></li> </ul> </li> <li id="no" title="pg2 " expanded="false">pg2<ul> <li><a href="pg2.html"> Top of manual page </a></li> <li title="create-1"><a href="pg2.html#create-1">create/1</a></li> <li title="delete-1"><a href="pg2.html#delete-1">delete/1</a></li> <li title="get_closest_pid-1"><a href="pg2.html#get_closest_pid-1">get_closest_pid/1</a></li> <li title="get_members-1"><a href="pg2.html#get_members-1">get_members/1</a></li> <li title="get_local_members-1"><a href="pg2.html#get_local_members-1">get_local_members/1</a></li> <li title="join-2"><a href="pg2.html#join-2">join/2</a></li> <li title="leave-2"><a href="pg2.html#leave-2">leave/2</a></li> <li title="which_groups-0"><a href="pg2.html#which_groups-0">which_groups/0</a></li> <li title="start-0"><a href="pg2.html#start-0">start/0</a></li> <li title="start_link-0"><a href="pg2.html#start_link-0">start_link/0</a></li> </ul> </li> <li id="no" title="rpc " expanded="false">rpc<ul> <li><a href="rpc.html"> Top of manual page </a></li> <li title="call-4"><a href="rpc.html#call-4">call/4</a></li> <li title="call-5"><a href="rpc.html#call-5">call/5</a></li> <li title="block_call-4"><a href="rpc.html#block_call-4">block_call/4</a></li> <li title="block_call-5"><a href="rpc.html#block_call-5">block_call/5</a></li> <li title="async_call-4"><a href="rpc.html#async_call-4">async_call/4</a></li> <li title="yield-1"><a href="rpc.html#yield-1">yield/1</a></li> <li title="nb_yield-1"><a href="rpc.html#nb_yield-1">nb_yield/1</a></li> <li title="nb_yield-2"><a href="rpc.html#nb_yield-2">nb_yield/2</a></li> <li title="multicall-3"><a href="rpc.html#multicall-3">multicall/3</a></li> <li title="multicall-4"><a href="rpc.html#multicall-4">multicall/4</a></li> <li title="multicall-5"><a href="rpc.html#multicall-5">multicall/5</a></li> <li title="cast-4"><a href="rpc.html#cast-4">cast/4</a></li> <li title="eval_everywhere-3"><a href="rpc.html#eval_everywhere-3">eval_everywhere/3</a></li> <li title="eval_everywhere-4"><a href="rpc.html#eval_everywhere-4">eval_everywhere/4</a></li> <li title="abcast-2"><a href="rpc.html#abcast-2">abcast/2</a></li> <li title="abcast-3"><a href="rpc.html#abcast-3">abcast/3</a></li> <li title="sbcast-2"><a href="rpc.html#sbcast-2">sbcast/2</a></li> <li title="sbcast-3"><a href="rpc.html#sbcast-3">sbcast/3</a></li> <li title="server_call-4"><a href="rpc.html#server_call-4">server_call/4</a></li> <li title="multi_server_call-2"><a href="rpc.html#multi_server_call-2">multi_server_call/2</a></li> <li title="multi_server_call-3"><a href="rpc.html#multi_server_call-3">multi_server_call/3</a></li> <li title="safe_multi_server_call-2"><a href="rpc.html#safe_multi_server_call-2">safe_multi_server_call/2</a></li> <li title="safe_multi_server_call-3"><a href="rpc.html#safe_multi_server_call-3">safe_multi_server_call/3</a></li> <li title="parallel_eval-1"><a href="rpc.html#parallel_eval-1">parallel_eval/1</a></li> <li title="pmap-3"><a href="rpc.html#pmap-3">pmap/3</a></li> <li title="pinfo-1"><a href="rpc.html#pinfo-1">pinfo/1</a></li> <li title="pinfo-2"><a href="rpc.html#pinfo-2">pinfo/2</a></li> </ul> </li> <li id="no" title="seq_trace " expanded="false">seq_trace<ul> <li><a href="seq_trace.html"> Top of manual page </a></li> <li title="set_token-1"><a href="seq_trace.html#set_token-1">set_token/1</a></li> <li title="set_token-2"><a href="seq_trace.html#set_token-2">set_token/2</a></li> <li title="get_token-0"><a href="seq_trace.html#get_token-0">get_token/0</a></li> <li title="get_token-1"><a href="seq_trace.html#get_token-1">get_token/1</a></li> <li title="print-1"><a href="seq_trace.html#print-1">print/1</a></li> <li title="print-2"><a href="seq_trace.html#print-2">print/2</a></li> <li title="reset_trace-0"><a href="seq_trace.html#reset_trace-0">reset_trace/0</a></li> <li title="set_system_tracer-1"><a href="seq_trace.html#set_system_tracer-1">set_system_tracer/1</a></li> <li title="get_system_tracer-0"><a href="seq_trace.html#get_system_tracer-0">get_system_tracer/0</a></li> </ul> </li> <li title="user"><a href="user.html">user</a></li> <li id="no" title="wrap_log_reader " expanded="false">wrap_log_reader<ul> <li><a href="wrap_log_reader.html"> Top of manual page </a></li> <li title="chunk-1"><a href="wrap_log_reader.html#chunk-1">chunk/1</a></li> <li title="chunk-2"><a href="wrap_log_reader.html#chunk-2">chunk/2</a></li> <li title="close-1"><a href="wrap_log_reader.html#close-1">close/1</a></li> <li title="open-1"><a href="wrap_log_reader.html#open-1">open/1</a></li> <li title="open-2"><a href="wrap_log_reader.html#open-2">open/2</a></li> </ul> </li> <li title="zlib"><a href="zlib.html">zlib</a></li> <li title="app"><a href="app.html">app</a></li> <li title="config"><a href="config.html">config</a></li> <li title="packages"><a href="packages.html">packages</a></li> </ul> </div></div> <div id="content"> <div class="innertube"> <!-- refpage --><center><h1>gen_sctp</h1></center> <h3>MODULE</h3> <div class="REFBODY">gen_sctp</div> <h3>MODULE SUMMARY</h3> <div class="REFBODY">The gen_sctp module provides functions for communicating with sockets using the SCTP protocol.</div> <h3>DESCRIPTION</h3> <div class="REFBODY"><p> <p>The <span class="code">gen_sctp</span> module provides functions for communicating with sockets using the SCTP protocol. The implementation assumes that the OS kernel supports SCTP <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">(RFC2960)</a></span> through the user-level <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions.</a></span> During development this implementation was tested on Linux Fedora Core 5.0 (kernel 2.6.15-2054 or later is needed), and on Solaris 10, 11. During OTP adaptation it was tested on SUSE Linux Enterprise Server 10 (x86_64) kernel 2.6.16.27-0.6-smp, with lksctp-tools-1.0.6, briefly on Solaris 10, and later on SUSE Linux Enterprise Server 10 Service Pack 1 (x86_64) kernel 2.6.16.54-0.2.3-smp with lksctp-tools-1.0.7, and later also on FreeBSD 8.2. </p> <p> This module was written for one-to-many style sockets (type <span class="code">seqpacket</span>). With the addition of <span class="bold_code"><a href="#peeloff-2">peeloff/2</a></span>, one-to-one style sockets (type <span class="code">stream</span>) were introduced. </p> <p>Record definitions for the <span class="code">gen_sctp</span> module can be found using:</p> <div class="example"><pre> -include_lib("kernel/include/inet_sctp.hrl"). </pre></div> <p>These record definitions use the "new" spelling 'adaptation', not the deprecated 'adaption', regardless of which spelling the underlying C API uses.</p> </p></div> <h3><a name="id121544">CONTENTS</a></h3> <div class="REFBODY"> <a name="contents"></a> <ul> <li><span class="bold_code"><a href="#types">DATA TYPES</a></span></li> <li><span class="bold_code"><a href="#exports">EXPORTS</a></span></li> <li><span class="bold_code"><a href="#options">SCTP SOCKET OPTIONS</a></span></li> <li><span class="bold_code"><a href="#examples">SCTP EXAMPLES</a></span></li> <li><span class="bold_code"><a href="#seealso">SEE ALSO</a></span></li> </ul> <a name="types"></a> </div> <h3>DATA TYPES</h3> <p><span class="bold_code"><a name="type-assoc_id">assoc_id()</a></span></p> <div class="REFBODY"><p> <p>An opaque term returned in for example #sctp_paddr_change{} that identifies an association for an SCTP socket. The term is opaque except for the special value <span class="code">0</span> that has a meaning such as "the whole endpoint" or "all future associations". </p> </p></div> <p> <span class="bold_code"><a name="type-option">option()</a> = {active, true | false | once}<br> | {buffer, integer() >= 0}<br> | {dontroute, boolean()}<br> | {linger, {boolean(), integer() >= 0}}<br> | {mode, list | binary}<br> | list<br> | binary<br> | {priority, integer() >= 0}<br> | {recbuf, integer() >= 0}<br> | {reuseaddr, boolean()}<br> | {sctp_adaptation_layer, #sctp_setadaptation{}}<br> | {sctp_associnfo, #sctp_assocparams{}}<br> | {sctp_autoclose, integer() >= 0}<br> | {sctp_default_send_param, #sctp_sndrcvinfo{}}<br> | {sctp_delayed_ack_time, #sctp_assoc_value{}}<br> | {sctp_disable_fragments, boolean()}<br> | {sctp_events, #sctp_event_subscribe{}}<br> | {sctp_get_peer_addr_info, #sctp_paddrinfo{}}<br> | {sctp_i_want_mapped_v4_addr, boolean()}<br> | {sctp_initmsg, #sctp_initmsg{}}<br> | {sctp_maxseg, integer() >= 0}<br> | {sctp_nodelay, boolean()}<br> | {sctp_peer_addr_params, #sctp_paddrparams{}}<br> | {sctp_primary_addr, #sctp_prim{}}<br> | {sctp_rtoinfo, #sctp_rtoinfo{}}<br> | {sctp_set_peer_primary_addr, #sctp_setpeerprim{}}<br> | {sctp_status, #sctp_status{}}<br> | {sndbuf, integer() >= 0}<br> | {tos, integer() >= 0}</span><br></p> <div class="REFBODY"><p> <p>One of the <span class="bold_code"><a href="#options">SCTP Socket Options.</a></span></p> </p></div> <p> <span class="bold_code"><a name="type-option_name">option_name()</a> = active<br> | buffer<br> | dontroute<br> | linger<br> | mode<br> | priority<br> | recbuf<br> | reuseaddr<br> | sctp_adaptation_layer<br> | sctp_associnfo<br> | sctp_autoclose<br> | sctp_default_send_param<br> | sctp_delayed_ack_time<br> | sctp_disable_fragments<br> | sctp_events<br> | sctp_get_peer_addr_info<br> | sctp_i_want_mapped_v4_addr<br> | sctp_initmsg<br> | sctp_maxseg<br> | sctp_nodelay<br> | sctp_peer_addr_params<br> | sctp_primary_addr<br> | sctp_rtoinfo<br> | sctp_set_peer_primary_addr<br> | sctp_status<br> | sndbuf<br> | tos</span><br></p> <div class="REFBODY"><p><a name="type-sctp_socket"></a></p></div> <p><span class="bold_code"><a name="type-sctp_socket">sctp_socket()</a></span></p> <div class="REFBODY"><p> <p>Socket identifier returned from <span class="code">open/*</span>.</p> <a name="exports"></a> </p></div> <h3>EXPORTS</h3> <p><a name="abort-2"></a><span class="bold_code">abort(Socket, Assoc) -> ok | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{}</span></div> </div></p> <div class="REFBODY"><p> <p>Abnormally terminates the association given by <span class="code">Assoc</span>, without flushing of unsent data. The socket itself remains open. Other associations opened on this socket are still valid, and it can be used in new associations.</p> </p></div> <p><a name="close-1"></a><span class="bold_code">close(Socket) -> ok | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> </div></p> <div class="REFBODY"><p> <p>Completely closes the socket and all associations on it. The unsent data is flushed as in <span class="code">eof/2</span>. The <span class="code">close/1</span> call is blocking or otherwise depending of the value of the <span class="bold_code"><a href="inet.html#option-linger">linger</a></span> socket <span class="bold_code"><a href="#options">option</a></span>. If <span class="code">close</span> does not linger or linger timeout expires, the call returns and the data is flushed in the background.</p> </p></div> <p><a name="connect-4"></a><span class="bold_code">connect(Socket, Addr, Port, Opts) -><br> {ok, Assoc} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Addr = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span> | <span class="bold_code"><a href="inet.html#type-hostname">inet:hostname()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Port = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Opts = [Opt :: <span class="bold_code"><a href="#type-option">option()</a></span>]</span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{}</span></div> </div></p> <div class="REFBODY"><p> <p>Same as <span class="code">connect(Socket, Addr, Port, Opts, infinity)</span>.</p> </p></div> <p><a name="connect-5"></a><span class="bold_code">connect(Socket, Addr, Port, Opts, Timeout) -><br> {ok, Assoc} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Addr = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span> | <span class="bold_code"><a href="inet.html#type-hostname">inet:hostname()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Port = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Opts = [Opt :: <span class="bold_code"><a href="#type-option">option()</a></span>]</span></div> <div class="REFTYPES"><span class="bold_code">Timeout = timeout()</span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{}</span></div> </div></p> <div class="REFBODY"><p> <p>Establishes a new association for the socket <span class="code">Socket</span>, with the peer (SCTP server socket) given by <span class="code">Addr</span> and <span class="code">Port</span>. The <span class="code">Timeout</span>, is expressed in milliseconds. A socket can be associated with multiple peers.</p> <p><strong>WARNING:</strong>Using a value of <span class="code">Timeout</span> less than the maximum time taken by the OS to establish an association (around 4.5 minutes if the default values from RFC 4960 are used) can result in inconsistent or incorrect return values. This is especially relevant for associations sharing the same <span class="code">Socket</span> (i.e. source address and port) since the controlling process blocks until <span class="code">connect/*</span> returns. <span class="bold_code"><a href="#connect_init-4">connect_init/*</a></span> provides an alternative not subject to this limitation.</p> <p><a name="record-sctp_assoc_change"></a> The result of <span class="code">connect/*</span> is an <span class="code">#sctp_assoc_change{}</span> event which contains, in particular, the new <span class="bold_code"><a href="#type-assoc_id">Association ID</a></span>.</p> <div class="example"><pre> #sctp_assoc_change{ state = atom(), error = atom(), outbound_streams = integer(), inbound_streams = integer(), assoc_id = assoc_id() } </pre></div> <p>The number of outbound and inbound streams can be set by giving an <span class="code">sctp_initmsg</span> option to <span class="code">connect</span> as in:</p> <div class="example"><pre> connect(Socket, Ip, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=OutStreams, max_instreams=MaxInStreams}}]) </pre></div> <p>All options <span class="code">Opt</span> are set on the socket before the association is attempted. If an option record has got undefined field values, the options record is first read from the socket for those values. In effect, <span class="code">Opt</span> option records only define field values to change before connecting.</p> <p>The returned <span class="code">outbound_streams</span> and <span class="code">inbound_streams</span> are the actual stream numbers on the socket, which may be different from the requested values (<span class="code">OutStreams</span> and <span class="code">MaxInStreams</span> respectively) if the peer requires lower values.</p> <p>The following values of <span class="code">state</span> are possible:</p> <ul> <li> <p><span class="code">comm_up</span>: association successfully established. This indicates a successful completion of <span class="code">connect</span>.</p> </li> <li> <p><span class="code">cant_assoc</span>: association cannot be established (<span class="code">connect/*</span> failure).</p> </li> </ul> <p>All other states do not normally occur in the output from <span class="code">connect/*</span>. Rather, they may occur in <span class="code">#sctp_assoc_change{}</span> events received instead of data in <span class="bold_code"><a href="#recv-1">recv/*</a></span> calls. All of them indicate losing the association due to various error conditions, and are listed here for the sake of completeness. The <span class="code">error</span> field may provide more detailed diagnostics.</p> <ul> <li> <p><span class="code">comm_lost</span>;</p> </li> <li> <p><span class="code">restart</span>;</p> </li> <li> <p><span class="code">shutdown_comp</span>.</p> </li> </ul> </p></div> <p><a name="connect_init-4"></a><span class="bold_code">connect_init(Socket, Addr, Port, Opts) -><br> ok | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Addr = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span> | <span class="bold_code"><a href="inet.html#type-hostname">inet:hostname()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Port = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Opts = [<span class="bold_code"><a href="#type-option">option()</a></span>]</span></div> </div></p> <div class="REFBODY"><p> <p>Same as <span class="code">connect_init(Socket, Addr, Port, Opts, infinity)</span>.</p> </p></div> <p><a name="connect_init-5"></a><span class="bold_code">connect_init(Socket, Addr, Port, Opts, Timeout) -><br> ok | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Addr = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span> | <span class="bold_code"><a href="inet.html#type-hostname">inet:hostname()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Port = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Opts = [<span class="bold_code"><a href="#type-option">option()</a></span>]</span></div> <div class="REFTYPES"><span class="bold_code">Timeout = timeout()</span></div> </div></p> <div class="REFBODY"><p> <p>Initiates a new association for the socket <span class="code">Socket</span>, with the peer (SCTP server socket) given by <span class="code">Addr</span> and <span class="code">Port</span>.</p> <p>The fundamental difference between this API and <span class="code">connect/*</span> is that the return value is that of the underlying OS connect(2) system call. If <span class="code">ok</span> is returned then the result of the association establishement is received by the calling process as an <span class="bold_code"><a href="#record-sctp_assoc_change"> #sctp_assoc_change{}</a></span> event. The calling process must be prepared to receive this, or poll for it using <span class="code">recv/*</span> depending on the value of the active option.</p> <p>The parameters are as described in <span class="bold_code"><a href="#connect-5">connect/*</a></span>, with the exception of the <span class="code">Timeout</span> value.</p> <p>The timer associated with <span class="code">Timeout</span> only supervises IP resolution of <span class="code">Addr</span></p> </p></div> <p><a name="controlling_process-2"></a><span class="bold_code">controlling_process(Socket, Pid) -> ok | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Pid = pid()</span></div> <div class="REFTYPES"><span class="bold_code">Reason = closed | not_owner | <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span></span></div> </div></p> <div class="REFBODY"><p> <p>Assigns a new controlling process <span class="code">Pid</span> to <span class="code">Socket</span>. Same implementation as <span class="code">gen_udp:controlling_process/2</span>.</p> </p></div> <p><a name="eof-2"></a><span class="bold_code">eof(Socket, Assoc) -> ok | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{}</span></div> <div class="REFTYPES"><span class="bold_code">Reason = term()</span></div> </div></p> <div class="REFBODY"><p> <p>Gracefully terminates the association given by <span class="code">Assoc</span>, with flushing of all unsent data. The socket itself remains open. Other associations opened on this socket are still valid, and it can be used in new associations.</p> </p></div> <p><a name="listen-2"></a><span class="bold_code">listen(Socket, IsServer) -> ok | {error, Reason}</span><br><span class="bold_code">listen(Socket, Backlog) -> ok | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Backlog = integer()</span></div> <div class="REFTYPES"><span class="bold_code">Reason = term()</span></div> </div></p> <div class="REFBODY"><p> <p>Sets up a socket to listen on the IP address and port number it is bound to.</p> <p>For type <span class="code">seqpacket</span> sockets (the default) <span class="code">IsServer</span> must be <span class="code">true</span> or <span class="code">false</span>. In contrast to TCP, in SCTP there is no listening queue length. If <span class="code">IsServer</span> is <span class="code">true</span> the socket accepts new associations, i.e. it will become an SCTP server socket.</p> <p>For type <span class="code">stream</span> sockets Backlog defines the backlog queue length just like in TCP.</p> </p></div> <p><a name="open-0"></a><span class="bold_code">open() -> {ok, Socket} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><a name="open-1"></a><span class="bold_code">open(Port) -> {ok, Socket} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><span class="bold_code">open(Opts) -> {ok, Socket} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><a name="open-2"></a><span class="bold_code">open(Port, Opts) -> {ok, Socket} | {error, <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span>}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Opts = [Opt]</span></div> <div class="REFTYPES"><span class="bold_code">Opt = {ip, IP}<br> | {ifaddr, IP}<br> | <span class="bold_code"><a href="inet.html#type-address_family">inet:address_family()</a></span><br> | {port, Port}<br> | {type, SockType}<br> | <span class="bold_code"><a href="#type-option">option()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">IP = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span> | any | loopback</span></div> <div class="REFTYPES"><span class="bold_code">Port = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">SockType = seqpacket | stream</span></div> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> </div></p> <div class="REFBODY"><p> <p>Creates an SCTP socket and binds it to the local addresses specified by all <span class="code">{ip,IP}</span> (or synonymously <span class="code">{ifaddr,IP}</span>) options (this feature is called SCTP multi-homing). The default <span class="code">IP</span> and <span class="code">Port</span> are <span class="code">any</span> and <span class="code">0</span>, meaning bind to all local addresses on any one free port.</p> <p>Other options are:</p> <dl> <dt><strong><span class="code">inet6</span></strong></dt> <dd> <p>Set up the socket for IPv6.</p> </dd> <dt><strong><span class="code">inet</span></strong></dt> <dd> <p>Set up the socket for IPv4. This is the default.</p> </dd> </dl> <p>A default set of socket <span class="bold_code"><a href="#options">options</a></span> is used. In particular, the socket is opened in <span class="bold_code"><a href="#option-binary">binary</a></span> and <span class="bold_code"><a href="#option-active">passive</a></span> mode, with SockType <span class="code">seqpacket</span>, and with reasonably large <span class="bold_code"><a href="inet.html#option-sndbuf">kernel</a></span> and driver <span class="bold_code"><a href="inet.html#option-buffer">buffers.</a></span></p> </p></div> <p><a name="peeloff-2"></a><span class="bold_code">peeloff(Socket, Assoc) -> {ok, NewSocket} | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{} | <span class="bold_code"><a href="#type-assoc_id">assoc_id()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">NewSocket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Reason = term()</span></div> </div></p> <div class="REFBODY"><p> <p> Branch off an existing association Assoc in a socket Socket of type <span class="code">seqpacket</span> (one-to-may style) into a new socket NewSocket of type <span class="code">stream</span> (one-to-one style). </p> <p> The existing association argument Assoc can be either a <span class="bold_code"><a href="#record-sctp_assoc_change"> #sctp_assoc_change{} </a></span> record as returned from e.g <span class="bold_code"><a href="#recv-2">recv/*</a></span>, <span class="bold_code"><a href="#connect-5">connect/*</a></span> or from a listening socket in active mode. Or it can be just the field <span class="code">assoc_id</span> integer from such a record. </p> </p></div> <p><a name="recv-1"></a><span class="bold_code">recv(Socket) -><br> {ok, {FromIP, FromPort, AncData, Data}} | {error, Reason}</span><br><a name="recv-2"></a><span class="bold_code">recv(Socket, Timeout) -><br> {ok, {FromIP, FromPort, AncData, Data}} | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Timeout = timeout()</span></div> <div class="REFTYPES"><span class="bold_code">FromIP = <span class="bold_code"><a href="inet.html#type-ip_address">inet:ip_address()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">FromPort = <span class="bold_code"><a href="inet.html#type-port_number">inet:port_number()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">AncData = [#sctp_sndrcvinfo{}]</span></div> <div class="REFTYPES"><span class="bold_code">Data = binary()<br> | string()<br> | #sctp_sndrcvinfo{}<br> | #sctp_assoc_change{}<br> | #sctp_paddr_change{}<br> | #sctp_adaptation_event{}</span></div> <div class="REFTYPES"><span class="bold_code">Reason = <span class="bold_code"><a href="inet.html#type-posix">inet:posix()</a></span><br> | #sctp_send_failed{}<br> | #sctp_paddr_change{}<br> | #sctp_pdapi_event{}<br> | #sctp_remote_error{}<br> | #sctp_shutdown_event{}</span></div> </div></p> <div class="REFBODY"><p> <p>Receives the <span class="code">Data</span> message from any association of the socket. If the receive times out <span class="code">{error,timeout</span> is returned. The default timeout is <span class="code">infinity</span>. <span class="code">FromIP</span> and <span class="code">FromPort</span> indicate the sender's address.</p> <p><span class="code">AncData</span> is a list of Ancillary Data items which may be received along with the main <span class="code">Data</span>. This list can be empty, or contain a single <span class="bold_code"><a href="#record-sctp_sndrcvinfo">#sctp_sndrcvinfo{}</a></span> record, if receiving of such ancillary data is enabled (see option <span class="bold_code"><a href="#option-sctp_events">sctp_events</a></span>). It is enabled by default, since such ancillary data provide an easy way of determining the association and stream over which the message has been received. (An alternative way would be to get the Association ID from the <span class="code">FromIP</span> and <span class="code">FromPort</span> using the <span class="bold_code"><a href="#option-sctp_get_peer_addr_info">sctp_get_peer_addr_info</a></span> socket option, but this would still not produce the Stream number).</p> <p>The actual <span class="code">Data</span> received may be a <span class="code">binary()</span>, or <span class="code">list()</span> of bytes (integers in the range 0 through 255) depending on the socket mode, or an SCTP Event. <a name="sctp_events"></a> The following SCTP Events are possible:</p> <ul> <li> <p><span class="bold_code"><a href="#record-sctp_sndrcvinfo">#sctp_sndrcvinfo{}</a></span></p> </li> <li> <p><span class="bold_code"><a href="#record-sctp_assoc_change">#sctp_assoc_change{}</a></span>;</p> </li> <li> <div class="example"><pre> #sctp_paddr_change{ addr = {ip_address(),port()}, state = atom(), error = integer(), assoc_id = assoc_id() } </pre></div> <p>Indicates change of the status of the peer's IP address given by <span class="code">addr</span> within the association <span class="code">assoc_id</span>. Possible values of <span class="code">state</span> (mostly self-explanatory) include:</p> <ul> <li> <p><span class="code">addr_unreachable</span>;</p> </li> <li> <p><span class="code">addr_available</span>;</p> </li> <li> <p><span class="code">addr_removed</span>;</p> </li> <li> <p><span class="code">addr_added</span>;</p> </li> <li> <p><span class="code">addr_made_prim</span>.</p> </li> <li> <p><span class="code">addr_confirmed</span>.</p> </li> </ul> <p>In case of an error (e.g. <span class="code">addr_unreachable</span>), the <span class="code">error</span> field provides additional diagnostics. In such cases, the <span class="code">#sctp_paddr_change{}</span> Event is automatically converted into an <span class="code">error</span> term returned by <span class="code">gen_sctp:recv</span>. The <span class="code">error</span> field value can be converted into a string using <span class="code">error_string/1</span>.</p> </li> <li> <div class="example"><pre> #sctp_send_failed{ flags = true | false, error = integer(), info = #sctp_sndrcvinfo{}, assoc_id = assoc_id() data = binary() } </pre></div> <p>The sender may receive this event if a send operation fails. The <span class="code">flags</span> is a Boolean specifying whether the data have actually been transmitted over the wire; <span class="code">error</span> provides extended diagnostics, use <span class="code">error_string/1</span>; <span class="code">info</span> is the original <span class="bold_code"><a href="#record-sctp_sndrcvinfo">#sctp_sndrcvinfo{}</a></span> record used in the failed <span class="bold_code"><a href="#send-3">send/*,</a></span> and <span class="code">data</span> is the whole original data chunk attempted to be sent.</p> <p>In the current implementation of the Erlang/SCTP binding, this Event is internally converted into an <span class="code">error</span> term returned by <span class="code">recv/*</span>.</p> </li> <li> <div class="example"><pre> #sctp_adaptation_event{ adaptation_ind = integer(), assoc_id = assoc_id() } </pre></div> <p>Delivered when a peer sends an Adaptation Layer Indication parameter (configured through the option <span class="bold_code"><a href="#option-sctp_adaptation_layer">sctp_adaptation_layer</a></span>). Note that with the current implementation of the Erlang/SCTP binding, this event is disabled by default.</p> </li> <li> <div class="example"><pre> #sctp_pdapi_event{ indication = sctp_partial_delivery_aborted, assoc_id = assoc_id() } </pre></div> <p>A partial delivery failure. In the current implementation of the Erlang/SCTP binding, this Event is internally converted into an <span class="code">error</span> term returned by <span class="code">recv/*</span>.</p> </li> </ul> </p></div> <p><a name="send-3"></a><span class="bold_code">send(Socket, SndRcvInfo, Data) -> ok | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">SndRcvInfo = #sctp_sndrcvinfo{}</span></div> <div class="REFTYPES"><span class="bold_code">Data = binary() | iolist()</span></div> <div class="REFTYPES"><span class="bold_code">Reason = term()</span></div> </div></p> <div class="REFBODY"><p> <p>Sends the <span class="code">Data</span> message with all sending parameters from a <span class="bold_code"><a href="#record-sctp_sndrcvinfo">#sctp_sndrcvinfo{}</a></span> record. This way, the user can specify the PPID (passed to the remote end) and Context (passed to the local SCTP layer) which can be used for example for error identification. However, such a fine level of user control is rarely required. The send/4 function is sufficient for most applications.</p> </p></div> <p><a name="send-4"></a><span class="bold_code">send(Socket, Assoc, Stream, Data) -> ok | {error, Reason}</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">Socket = <span class="bold_code"><a href="#type-sctp_socket">sctp_socket()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Assoc = #sctp_assoc_change{} | <span class="bold_code"><a href="#type-assoc_id">assoc_id()</a></span></span></div> <div class="REFTYPES"><span class="bold_code">Stream = integer()</span></div> <div class="REFTYPES"><span class="bold_code">Data = binary() | iolist()</span></div> <div class="REFTYPES"><span class="bold_code">Reason = term()</span></div> </div></p> <div class="REFBODY"><p> <p>Sends <span class="code">Data</span> message over an existing association and given stream.</p> </p></div> <p><a name="error_string-1"></a><span class="bold_code">error_string(ErrorNumber) -> ok | string() | unknown_error</span><br><div class="REFBODY"> <p>Types:</p> <div class="REFTYPES"><span class="bold_code">ErrorNumber = integer()</span></div> </div></p> <div class="REFBODY"><p> <p>Translates an SCTP error number from for example <span class="code">#sctp_remote_error{}</span> or <span class="code">#sctp_send_failed{}</span> into an explanatory string, or one of the atoms <span class="code">ok</span> for no error and <span class="code">undefined</span> for an unrecognized error.</p> </p></div> <h3><a name="id123058">SCTP SOCKET OPTIONS</a></h3> <div class="REFBODY"> <a name="options"></a> <p>The set of admissible SCTP socket options is by construction orthogonal to the sets of TCP, UDP and generic INET options: only those options which are explicitly listed below are allowed for SCTP sockets. Options can be set on the socket using <span class="code">gen_sctp:open/1,2</span> or <span class="code">inet:setopts/2</span>, retrieved using <span class="code">inet:getopts/2</span>, and when calling <span class="code">gen_sctp:connect/4,5</span> options can be changed.</p> <a name="option-binary"></a> <a name="option-list"></a> <dl> <dt><strong><span class="code">{mode, list|binary}</span> or just <span class="code">list</span> or <span class="code">binary</span></strong></dt> <dd> <p>Determines the type of data returned from <span class="code">gen_sctp:recv/1,2</span>.</p> <a name="option-active"></a> </dd> <dt><strong><span class="code">{active, true|false|once}</span></strong></dt> <dd> <ul> <li> <p>If <span class="code">false</span> (passive mode, the default), the caller needs to do an explicit <span class="code">gen_sctp:recv</span> call in order to retrieve the available data from the socket.</p> </li> <li> <p>If <span class="code">true</span> (full active mode), the pending data or events are sent to the owning process.</p> <p><strong>NB:</strong> This can cause the message queue to overflow, as there is no way to throttle the sender in this case (no flow control!).</p> </li> <li> <p>If <span class="code">once</span>, only one message is automatically placed in the message queue, after that the mode is automatically re-set to passive. This provides flow control as well as the possibility for the receiver to listen for its incoming SCTP data interleaved with other inter-process messages.</p> </li> </ul> </dd> <dt><strong><span class="code">{tos, integer()}</span></strong></dt> <dd> <p>Sets the Type-Of-Service field on the IP datagrams being sent, to the given value, which effectively determines a prioritization policy for the outbound packets. The acceptable values are system-dependent. TODO: we do not provide symbolic names for these values yet.</p> </dd> <dt><strong><span class="code">{priority, integer()}</span></strong></dt> <dd> <p>A protocol-independent equivalent of <span class="code">tos</span> above. Setting priority implies setting tos as well.</p> </dd> <dt><strong><span class="code">{dontroute, true|false}</span></strong></dt> <dd> <p>By default <span class="code">false</span>. If <span class="code">true</span>, the kernel does not send packets via any gateway, only sends them to directly connected hosts.</p> </dd> <dt><strong><span class="code">{reuseaddr, true|false}</span></strong></dt> <dd> <p>By default <span class="code">false</span>. If true, the local binding address <span class="code">{IP,Port}</span> of the socket can be re-used immediately: no waiting in the CLOSE_WAIT state is performed (may be required for high-throughput servers).</p> </dd> <dt><strong><span class="code">{sndbuf, integer()}</span></strong></dt> <dd> <p>The size, in bytes, of the *kernel* send buffer for this socket. Sending errors would occur for datagrams larger than <span class="code">val(sndbuf)</span>. Setting this option also adjusts the size of the driver buffer (see <span class="code">buffer</span> above).</p> </dd> <dt><strong><span class="code">{recbuf, integer()}</span></strong></dt> <dd> <p>The size, in bytes, of the *kernel* recv buffer for this socket. Sending errors would occur for datagrams larger than <span class="code">val(sndbuf)</span>. Setting this option also adjusts the size of the driver buffer (see <span class="code">buffer</span> above).</p> </dd> <dt><strong><span class="code">{sctp_module, module()}</span></strong></dt> <dd> <p> Override which callback module is used. Defaults to <span class="code">inet_sctp</span> for IPv4 and <span class="code">inet6_sctp</span> for IPv6. </p> </dd> <dt><strong><span class="code">{sctp_rtoinfo, #sctp_rtoinfo{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_rtoinfo{ assoc_id = assoc_id(), initial = integer(), max = integer(), min = integer() } </pre></div> <p>Determines re-transmission time-out parameters, in milliseconds, for the association(s) given by <span class="code">assoc_id</span>. If <span class="code">assoc_id = 0</span> (default) indicates the whole endpoint. See <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">RFC2960</a></span> and <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions for SCTP</a></span> for the exact semantics of the fields values.</p> </dd> <dt><strong><span class="code">{sctp_associnfo, #sctp_assocparams{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_assocparams{ assoc_id = assoc_id(), asocmaxrxt = integer(), number_peer_destinations = integer(), peer_rwnd = integer(), local_rwnd = integer(), cookie_life = integer() } </pre></div> <p>Determines association parameters for the association(s) given by <span class="code">assoc_id</span>. <span class="code">assoc_id = 0</span> (default) indicates the whole endpoint. See <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions for SCTP</a></span> for the discussion of their semantics. Rarely used.</p> </dd> <dt><strong><span class="code">{sctp_initmsg, #sctp_initmsg{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_initmsg{ num_ostreams = integer(), max_instreams = integer(), max_attempts = integer(), max_init_timeo = integer() } </pre></div> <p>Determines the default parameters which this socket attempts to negotiate with its peer while establishing an association with it. Should be set after <span class="code">open/*</span> but before the first <span class="code">connect/*</span>. <span class="code">#sctp_initmsg{}</span> can also be used as ancillary data with the first call of <span class="code">send/*</span> to a new peer (when a new association is created).</p> <ul> <li> <p><span class="code">num_ostreams</span>: number of outbound streams;</p> </li> <li> <p><span class="code">max_instreams</span>: max number of in-bound streams;</p> </li> <li> <p><span class="code">max_attempts</span>: max re-transmissions while establishing an association;</p> </li> <li> <p><span class="code">max_init_timeo</span>: time-out in milliseconds for establishing an association.</p> </li> </ul> </dd> <dt><strong><span class="code">{sctp_autoclose, integer() >= 0}</span></strong></dt> <dd> <p>Determines the time (in seconds) after which an idle association is automatically closed. <span class="code">0</span> means that the association is never automatically closed.</p> </dd> <dt><strong><span class="code">{sctp_nodelay, true|false}</span></strong></dt> <dd> <p>Turns on|off the Nagle algorithm for merging small packets into larger ones (which improves throughput at the expense of latency).</p> </dd> <dt><strong><span class="code">{sctp_disable_fragments, true|false}</span></strong></dt> <dd> <p>If <span class="code">true</span>, induces an error on an attempt to send a message which is larger than the current PMTU size (which would require fragmentation/re-assembling). Note that message fragmentation does not affect the logical atomicity of its delivery; this option is provided for performance reasons only.</p> </dd> <dt><strong><span class="code">{sctp_i_want_mapped_v4_addr, true|false}</span></strong></dt> <dd> <p>Turns on|off automatic mapping of IPv4 addresses into IPv6 ones (if the socket address family is AF_INET6).</p> </dd> <dt><strong><span class="code">{sctp_maxseg, integer()}</span></strong></dt> <dd> <p>Determines the maximum chunk size if message fragmentation is used. If <span class="code">0</span>, the chunk size is limited by the Path MTU only.</p> </dd> <dt><strong><span class="code">{sctp_primary_addr, #sctp_prim{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_prim{ assoc_id = assoc_id(), addr = {IP, Port} } IP = ip_address() Port = port_number() </pre></div> <p>For the association given by <span class="code">assoc_id</span>, <span class="code">{IP,Port}</span> must be one of the peer's addresses. This option determines that the given address is treated by the local SCTP stack as the peer's primary address.</p> </dd> <dt><strong><span class="code">{sctp_set_peer_primary_addr, #sctp_setpeerprim{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_setpeerprim{ assoc_id = assoc_id(), addr = {IP, Port} } IP = ip_address() Port = port_number() </pre></div> <p>When set, informs the peer that it should use <span class="code">{IP, Port}</span> as the primary address of the local endpoint for the association given by <span class="code">assoc_id</span>.</p> <a name="option-sctp_adaptation_layer"></a> </dd> <dt><strong><span class="code">{sctp_adaptation_layer, #sctp_setadaptation{}}</span></strong></dt> <dd> <a name="record-sctp_setadaptation"></a> <div class="example"><pre> #sctp_setadaptation{ adaptation_ind = integer() } </pre></div> <p>When set, requests that the local endpoint uses the value given by <span class="code">adaptation_ind</span> as the Adaptation Indication parameter for establishing new associations. See <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">RFC2960</a></span> and <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extenstions for SCTP</a></span> for more details.</p> </dd> <dt><strong><span class="code">{sctp_peer_addr_params, #sctp_paddrparams{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_paddrparams{ assoc_id = assoc_id(), address = {IP, Port}, hbinterval = integer(), pathmaxrxt = integer(), pathmtu = integer(), sackdelay = integer(), flags = list() } IP = ip_address() Port = port_number() </pre></div> <p>This option determines various per-address parameters for the association given by <span class="code">assoc_id</span> and the peer address <span class="code">address</span> (the SCTP protocol supports multi-homing, so more than 1 address can correspond to a given association).</p> <ul> <li> <p><span class="code">hbinterval</span>: heartbeat interval, in milliseconds;</p> </li> <li> <p><span class="code">pathmaxrxt</span>: max number of retransmissions before this address is considered unreachable (and an alternative address is selected);</p> </li> <li> <p><span class="code">pathmtu</span>: fixed Path MTU, if automatic discovery is disabled (see <span class="code">flags</span> below);</p> </li> <li> <p><span class="code">sackdelay</span>: delay in milliseconds for SAC messages (if the delay is enabled, see <span class="code">flags</span> below);</p> </li> <li> <p><span class="code">flags</span>: the following flags are available:</p> <ul> <li> <p><span class="code">hb_enable</span>: enable heartbeat; </p> </li> <li> <p><span class="code">hb_disable</span>: disable heartbeat;</p> </li> <li> <p><span class="code">hb_demand</span>: initiate heartbeat immediately;</p> </li> <li> <p><span class="code">pmtud_enable</span>: enable automatic Path MTU discovery;</p> </li> <li> <p><span class="code">pmtud_disable</span>: disable automatic Path MTU discovery;</p> </li> <li> <p><span class="code">sackdelay_enable</span>: enable SAC delay;</p> </li> <li> <p><span class="code">sackdelay_disable</span>: disable SAC delay.</p> </li> </ul> </li> </ul> </dd> <dt><strong><span class="code">{sctp_default_send_param, #sctp_sndrcvinfo{}}</span></strong></dt> <dd> <a name="record-sctp_sndrcvinfo"></a> <div class="example"><pre> #sctp_sndrcvinfo{ stream = integer(), ssn = integer(), flags = list(), ppid = integer(), context = integer(), timetolive = integer(), tsn = integer(), cumtsn = integer(), assoc_id = assoc_id() } </pre></div> <p><span class="code">#sctp_sndrcvinfo{}</span> is used both in this socket option, and as ancillary data while sending or receiving SCTP messages. When set as an option, it provides a default values for subsequent <span class="code">gen_sctp:send</span>calls on the association given by <span class="code">assoc_id</span>. <span class="code">assoc_id = 0</span> (default) indicates the whole endpoint. The following fields typically need to be specified by the sender:</p> <ul> <li> <p><span class="code">sinfo_stream</span>: stream number (0-base) within the association to send the messages through;</p> </li> <li> <p><span class="code">sinfo_flags</span>: the following flags are recognised:</p> <ul> <li> <p><span class="code">unordered</span>: the message is to be sent unordered;</p> </li> <li> <p><span class="code">addr_over</span>: the address specified in <span class="code">gen_sctp:send</span> overwrites the primary peer address;</p> </li> <li> <p><span class="code">abort</span>: abort the current association without flushing any unsent data;</p> </li> <li> <p><span class="code">eof</span>: gracefully shut down the current association, with flushing of unsent data.</p> </li> </ul> <p>Other fields are rarely used. See <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">RFC2960</a></span> and <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions for SCTP</a></span> for full information.</p> </li> </ul> <a name="option-sctp_events"></a> </dd> <dt><strong><span class="code">{sctp_events, #sctp_event_subscribe{}}</span></strong></dt> <dd> <a name="record-sctp_event_subscribe"></a> <div class="example"><pre> #sctp_event_subscribe{ data_io_event = true | false, association_event = true | false, address_event = true | false, send_failure_event = true | false, peer_error_event = true | false, shutdown_event = true | false, partial_delivery_event = true | false, adaptation_layer_event = true | false } </pre></div> <p>This option determines which <span class="bold_code"><a href="#sctp_events">SCTP Events</a></span> are to be received (via <span class="bold_code"><a href="#recv-1">recv/*</a></span>) along with the data. The only exception is <span class="code">data_io_event</span> which enables or disables receiving of <span class="bold_code"><a href="#record-sctp_sndrcvinfo">#sctp_sndrcvinfo{}</a></span> ancillary data, not events. By default, all flags except <span class="code">adaptation_layer_event</span> are enabled, although <span class="code">sctp_data_io_event</span> and <span class="code">association_event</span> are used by the driver itself and not exported to the user level.</p> </dd> <dt><strong><span class="code">{sctp_delayed_ack_time, #sctp_assoc_value{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_assoc_value{ assoc_id = assoc_id(), assoc_value = integer() } </pre></div> <p>Rarely used. Determines the ACK time (given by <span class="code">assoc_value</span> in milliseconds) for the given association or the whole endpoint if <span class="code">assoc_value = 0</span> (default).</p> </dd> <dt><strong><span class="code">{sctp_status, #sctp_status{}}</span></strong></dt> <dd> <div class="example"><pre> #sctp_status{ assoc_id = assoc_id(), state = atom(), rwnd = integer(), unackdata = integer(), penddata = integer(), instrms = integer(), outstrms = integer(), fragmentation_point = integer(), primary = #sctp_paddrinfo{} } </pre></div> <p>This option is read-only. It determines the status of the SCTP association given by <span class="code">assoc_id</span>. Possible values of <span class="code">state</span> follows. The state designations are mostly self-explanatory. <span class="code">state_empty</span> is the default which means that no other state is active:</p> <ul> <li> <p><span class="code">sctp_state_empty</span></p> </li> <li> <p><span class="code">sctp_state_closed</span></p> </li> <li> <p><span class="code">sctp_state_cookie_wait</span></p> </li> <li> <p><span class="code">sctp_state_cookie_echoed</span></p> </li> <li> <p><span class="code">sctp_state_established</span></p> </li> <li> <p><span class="code">sctp_state_shutdown_pending</span></p> </li> <li> <p><span class="code">sctp_state_shutdown_sent</span></p> </li> <li> <p><span class="code">sctp_state_shutdown_received</span></p> </li> <li> <p><span class="code">sctp_state_shutdown_ack_sent</span></p> </li> </ul> <p>The semantics of other fields is the following:</p> <ul> <li> <p><span class="code">sstat_rwnd</span>: the association peer's current receiver window size;</p> </li> <li> <p><span class="code">sstat_unackdata</span>: number of unacked data chunks;</p> </li> <li> <p><span class="code">sstat_penddata</span>: number of data chunks pending receipt;</p> </li> <li> <p><span class="code">sstat_instrms</span>: number of inbound streams;</p> </li> <li> <p><span class="code">sstat_outstrms</span>: number of outbound streams;</p> </li> <li> <p><span class="code">sstat_fragmentation_point</span>: message size at which SCTP fragmentation will occur;</p> </li> <li> <p><span class="code">sstat_primary</span>: information on the current primary peer address (see below for the format of <span class="code">#sctp_paddrinfo{}</span>).</p> </li> </ul> <a name="option-sctp_get_peer_addr_info"></a> </dd> <dt><strong><span class="code">{sctp_get_peer_addr_info, #sctp_paddrinfo{}}</span></strong></dt> <dd> <a name="record-sctp_paddrinfo"></a> <div class="example"><pre> #sctp_paddrinfo{ assoc_id = assoc_id(), address = {IP, Port}, state = inactive | active, cwnd = integer(), srtt = integer(), rto = integer(), mtu = integer() } IP = ip_address() Port = port_number() </pre></div> <p>This option is read-only. It determines the parameters specific to the peer's address given by <span class="code">address</span> within the association given by <span class="code">assoc_id</span>. The <span class="code">address</span> field must be set by the caller; all other fields are filled in on return. If <span class="code">assoc_id = 0</span> (default), the <span class="code">address</span> is automatically translated into the corresponding association ID. This option is rarely used; see <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">RFC2960</a></span> and <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions for SCTP</a></span> for the semantics of all fields.</p> </dd> </dl> </div> <h3><a name="id124317">SCTP EXAMPLES</a></h3> <div class="REFBODY"> <a name="examples"></a> <ul> <li> <p>Example of an Erlang SCTP Server which receives SCTP messages and prints them on the standard output:</p> <div class="example"><pre> -module(sctp_server). -export([server/0,server/1,server/2]). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). server() -> server(any, 2006). server([Host,Port]) when is_list(Host), is_list(Port) -> {ok, #hostent{h_addr_list = [IP|_]}} = inet:gethostbyname(Host), io:format("~w -> ~w~n", [Host, IP]), server([IP, list_to_integer(Port)]). server(IP, Port) when is_tuple(IP) orelse IP == any orelse IP == loopback, is_integer(Port) -> {ok,S} = gen_sctp:open(Port, [{recbuf,65536}, {ip,IP}]), io:format("Listening on ~w:~w. ~w~n", [IP,Port,S]), ok = gen_sctp:listen(S, true), server_loop(S). server_loop(S) -> case gen_sctp:recv(S) of {error, Error} -> io:format("SCTP RECV ERROR: ~p~n", [Error]); Data -> io:format("Received: ~p~n", [Data]) end, server_loop(S). </pre></div> </li> <li> <p>Example of an Erlang SCTP Client which interacts with the above Server. Note that in this example, the Client creates an association with the Server with 5 outbound streams. For this reason, sending of "Test 0" over Stream 0 succeeds, but sending of "Test 5" over Stream 5 fails. The client then <span class="code">abort</span>s the association, which results in the corresponding Event being received on the Server side.</p> <div class="example"><pre> -module(sctp_client). -export([client/0, client/1, client/2]). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). client() -> client([localhost]). client([Host]) -> client(Host, 2006); client([Host, Port]) when is_list(Host), is_list(Port) -> client(Host,list_to_integer(Port)), init:stop(). client(Host, Port) when is_integer(Port) -> {ok,S} = gen_sctp:open(), {ok,Assoc} = gen_sctp:connect (S, Host, Port, [{sctp_initmsg,#sctp_initmsg{num_ostreams=5}}]), io:format("Connection Successful, Assoc=~p~n", [Assoc]), io:write(gen_sctp:send(S, Assoc, 0, <<"Test 0">>)), io:nl(), timer:sleep(10000), io:write(gen_sctp:send(S, Assoc, 5, <<"Test 5">>)), io:nl(), timer:sleep(10000), io:write(gen_sctp:abort(S, Assoc)), io:nl(), timer:sleep(1000), gen_sctp:close(S). </pre></div> </li> <li> <p>A very simple Erlang SCTP Client which uses the connect_init API.</p> <div class="example"><pre>-module(ex3). -export([client/4]). -include_lib("kernel/include/inet.hrl"). -include_lib("kernel/include/inet_sctp.hrl"). client(Peer1, Port1, Peer2, Port2) when is_tuple(Peer1), is_integer(Port1), is_tuple(Peer2), is_integer(Port2) -> {ok,S} = gen_sctp:open(), SctpInitMsgOpt = {sctp_initmsg,#sctp_initmsg{num_ostreams=5}}, ActiveOpt = {active, true}, Opts = [SctpInitMsgOpt, ActiveOpt], ok = gen_sctp:connect(S, Peer1, Port1, Opts), ok = gen_sctp:connect(S, Peer2, Port2, Opts), io:format("Connections initiated~n", []), client_loop(S, Peer1, Port1, undefined, Peer2, Port2, undefined). client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) -> receive {sctp, S, Peer1, Port1, {_Anc, SAC}} when is_record(SAC, sctp_assoc_change), AssocId1 == undefined -> io:format("Association 1 connect result: ~p. AssocId: ~p~n", [SAC#sctp_assoc_change.state, SAC#sctp_assoc_change.assoc_id]), client_loop(S, Peer1, Port1, SAC#sctp_assoc_change.assoc_id, Peer2, Port2, AssocId2); {sctp, S, Peer2, Port2, {_Anc, SAC}} when is_record(SAC, sctp_assoc_change), AssocId2 == undefined -> io:format("Association 2 connect result: ~p. AssocId: ~p~n", [SAC#sctp_assoc_change.state, SAC#sctp_assoc_change.assoc_id]), client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, SAC#sctp_assoc_change.assoc_id); {sctp, S, Peer1, Port1, Data} -> io:format("Association 1: received ~p~n", [Data]), client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2); {sctp, S, Peer2, Port2, Data} -> io:format("Association 2: received ~p~n", [Data]), client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2); Other -> io:format("Other ~p~n", [Other]), client_loop(S, Peer1, Port1, AssocId1, Peer2, Port2, AssocId2) after 5000 -> ok end. </pre></div> </li> </ul> </div> <h3><a name="id124411">SEE ALSO</a></h3> <div class="REFBODY"> <a name="seealso"></a> <p><span class="bold_code"><a href="inet.html">inet(3)</a></span>, <span class="bold_code"><a href="gen_tcp.html">gen_tcp(3)</a></span>, <span class="bold_code"><a href="gen_udp.html">gen_udp(3)</a></span>, <span class="bold_code"><a href="http://www.rfc-archive.org/getrfc.php?rfc=2960">RFC2960</a></span> (Stream Control Transmission Protocol), <span class="bold_code"><a href="http://tools.ietf.org/html/draft-ietf-tsvwg-sctpsocket-13">Sockets API Extensions for SCTP.</a></span></p> </div> </div> <div class="footer"> <hr> <p>Copyright © 1997-2012 Ericsson AB. All Rights Reserved.</p> </div> </div> </div></body> </html>