PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/thread-self/root/usr/share/doc/libssh-devel/html/
Server: Linux server2.noticiasdecolima.com 4.18.0-553.30.1.el8_10.x86_64 #1 SMP Tue Nov 26 02:30:26 EST 2024 x86_64
IP: 107.161.180.42
Choose File :

Url:
Dir : //proc/thread-self/root/usr/share/doc/libssh-devel/html/libssh_tutor_threads.html

<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libssh: Chapter 8: Threads with libssh</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<script src="striped_bg.js"></script>
<link href="that_style.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libssh
   &#160;<span id="projectnumber">0.9.6</span>
   </div>
   <div id="projectbrief">The SSH library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="index.html">index</a></li><li class="navelem"><a class="el" href="libssh_tutorial.html">The Tutorial</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Chapter 8: Threads with libssh </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="threads_with_libssh"></a>
How to use libssh with threads</h1>
<p>libssh may be used in multithreaded applications, but under several conditions :</p><ul>
<li>Your system must support libpthread or, in Windows environment, CriticalSection based mutex control.</li>
<li>Since version 0.8.0, threads initialization is called automatically in the library constructor if libssh is dynamically linked. This means it is no longer necessary to call <a class="el" href="group__libssh.html#ga3ebf8d6920e563f3b032e3cd5277598e" title="Initialize global cryptographic data structures. ">ssh_init()</a>/ssh_finalize().</li>
<li>If libssh is statically linked, threading must be initialized by calling <a class="el" href="group__libssh.html#ga3ebf8d6920e563f3b032e3cd5277598e" title="Initialize global cryptographic data structures. ">ssh_init()</a> before using any of libssh provided functions. This initialization must be done outside of any threading context. Don't forget to call <a class="el" href="group__libssh.html#ga94a851d00248acde9cd7da084b491242" title="Finalize and cleanup all libssh and cryptographic data structures. ">ssh_finalize()</a> to avoid memory leak</li>
<li>At all times, you may use different sessions inside threads, make parallel connections, read/write on different sessions and so on. You <em>cannot</em> use a single session (or channels for a single session) in several threads at the same time. This will most likely lead to internal state corruption. This limitation is being worked out and will maybe disappear later.</li>
</ul>
<h2><a class="anchor" id="threads_init"></a>
Initialization of threads</h2>
<p>Since version 0.8.0, it is no longer necessary to call <a class="el" href="group__libssh.html#ga3ebf8d6920e563f3b032e3cd5277598e" title="Initialize global cryptographic data structures. ">ssh_init()</a>/ssh_finalize() if libssh is dynamically linked.</p>
<p>If libssh is statically linked, call <a class="el" href="group__libssh.html#ga3ebf8d6920e563f3b032e3cd5277598e" title="Initialize global cryptographic data structures. ">ssh_init()</a> before using any of libssh provided functions.</p>
<h2><a class="anchor" id="threads_pthread"></a>
Using libpthread with libssh</h2>
<p>Since version 0.8.0, libpthread is the default threads library used by libssh.</p>
<p>To use libpthread, simply link it to you application.</p>
<p>If you are using libssh statically linked, don't forget to call <a class="el" href="group__libssh.html#ga3ebf8d6920e563f3b032e3cd5277598e" title="Initialize global cryptographic data structures. ">ssh_init()</a> before using any of libssh provided functions (and <a class="el" href="group__libssh.html#ga94a851d00248acde9cd7da084b491242" title="Finalize and cleanup all libssh and cryptographic data structures. ">ssh_finalize()</a> in the end).</p>
<h2><a class="anchor" id="threads_other"></a>
Using another threading library</h2>
<p>Since version 0.8.0, libssh does not support custom threading libraries. The change makes sense since the newer versions for libcrypto (OpenSSL) and libgcrypt don't support custom threading libraries.</p>
<p>The default used threading library is libpthread. Alternatively, in Windows environment, CriticalSection based mutex control can be used.</p>
<p>If your system does not support libpthread nor CriticalSection based mutex control, unfortunately, you cannot use libssh in multithreaded scenarios.</p>
<p>Good luck ! </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.14
</small></address>
</body>
</html>