Commit a462a62a by Zeng Rixuan

Serialport、TCP\UDP

parent e0325328
SerialPort
\ No newline at end of file
Build
/Debug/*
*.log
/release/*
/Release/*
/.vs/*
/x64/*
/x86/*
cmake_minimum_required(VERSION 3.0.0)
project(helloword VERSION 0.1.0)
#reset output path
set ( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin )
set ( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib )
include(CTest)
enable_testing()
#set include file
include_directories (./inc)
#set source file
aux_source_directory ( . DIR_USR_SOURCE )
aux_source_directory ( ./src DIR_USR_SOURCE )
# find_library(WSOCK32_LIBRARY wsock32)
# find_library(WS2_32_LIBRARY ws2_32)
# add_executable(helloword main.cpp)
add_executable ( ${CMAKE_PROJECT_NAME} ${DIR_USR_SOURCE} )
if(WIN32)
target_link_libraries(${CMAKE_PROJECT_NAME} wsock32 ws2_32)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: D:/gitlab 目录参考</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">gitlab 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="subdirs" name="subdirs"></a>
目录</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">目录 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: D:/gitlab/windows_assist 目录参考</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">windows_assist 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="subdirs" name="subdirs"></a>
目录</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">目录 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_4914f6e54a235f5de227615847bb5f71.html">TCP_client</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: D:/gitlab/windows_assist/TCP_client 目录参考</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li><li class="navelem"><a class="el" href="dir_4914f6e54a235f5de227615847bb5f71.html">TCP_client</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">TCP_client 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="files" name="files"></a>
文件</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">文件 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html">main.cpp</a></td></tr>
<tr class="memdesc:main_8cpp"><td class="mdescLeft">&#160;</td><td class="mdescRight">@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
/*
@licstart The following is the entire license notice for the JavaScript code in this file.
The MIT License (MIT)
Copyright (C) 1997-2020 by Dimitri van Heesch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@licend The above is the entire license notice for the JavaScript code in this file
*/
function toggleVisibility(linkObj)
{
var base = $(linkObj).attr('id');
var summary = $('#'+base+'-summary');
var content = $('#'+base+'-content');
var trigger = $('#'+base+'-trigger');
var src=$(trigger).attr('src');
if (content.is(':visible')===true) {
content.hide();
summary.show();
$(linkObj).addClass('closed').removeClass('opened');
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
content.show();
summary.hide();
$(linkObj).removeClass('closed').addClass('opened');
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
}
return false;
}
function updateStripes()
{
$('table.directory tr').
removeClass('even').filter(':visible:even').addClass('even');
}
function toggleLevel(level)
{
$('table.directory tr').each(function() {
var l = this.id.split('_').length-1;
var i = $('#img'+this.id.substring(3));
var a = $('#arr'+this.id.substring(3));
if (l<level+1) {
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
a.html('&#9660;');
$(this).show();
} else if (l==level+1) {
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
a.html('&#9658;');
$(this).show();
} else {
$(this).hide();
}
});
updateStripes();
}
function toggleFolder(id)
{
// the clicked row
var currentRow = $('#row_'+id);
// all rows after the clicked row
var rows = currentRow.nextAll("tr");
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
// only match elements AFTER this one (can't hide elements before)
var childRows = rows.filter(function() { return this.id.match(re); });
// first row is visible we are HIDING
if (childRows.filter(':first').is(':visible')===true) {
// replace down arrow by right arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
currentRowSpans.filter(".arrow").html('&#9658;');
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
} else { // we are SHOWING
// replace right arrow by down arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
currentRowSpans.filter(".arrow").html('&#9660;');
// replace down arrows by right arrows for child rows
var childRowsSpans = childRows.find("span");
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
childRowsSpans.filter(".arrow").html('&#9658;');
childRows.show(); //show all children
}
updateStripes();
}
function toggleInherit(id)
{
var rows = $('tr.inherit.'+id);
var img = $('tr.inherit_header.'+id+' img');
var src = $(img).attr('src');
if (rows.filter(':first').is(':visible')===true) {
rows.css('display','none');
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
rows.css('display','table-row'); // using show() causes jump in firefox
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
}
}
/* @license-end */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: 文件列表</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">文件列表</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock">这里列出了所有文件,并附带简要说明:</div><div class="directory">
<div class="levels">[详情级别 <span onclick="javascript:toggleLevel(1);">1</span><span onclick="javascript:toggleLevel(2);">2</span><span onclick="javascript:toggleLevel(3);">3</span><span onclick="javascript:toggleLevel(4);">4</span>]</div><table class="directory">
<tr id="row_0_" class="even"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_0_" class="arrow" onclick="toggleFolder('0_')">&#9660;</span><span id="img_0_" class="iconfopen" onclick="toggleFolder('0_')">&#160;</span><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html" target="_self">gitlab</a></td><td class="desc"></td></tr>
<tr id="row_0_0_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span id="arr_0_0_" class="arrow" onclick="toggleFolder('0_0_')">&#9660;</span><span id="img_0_0_" class="iconfopen" onclick="toggleFolder('0_0_')">&#160;</span><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html" target="_self">windows_assist</a></td><td class="desc"></td></tr>
<tr id="row_0_0_0_" class="even"><td class="entry"><span style="width:32px;display:inline-block;">&#160;</span><span id="arr_0_0_0_" class="arrow" onclick="toggleFolder('0_0_0_')">&#9660;</span><span id="img_0_0_0_" class="iconfopen" onclick="toggleFolder('0_0_0_')">&#160;</span><a class="el" href="dir_4914f6e54a235f5de227615847bb5f71.html" target="_self">TCP_client</a></td><td class="desc"></td></tr>
<tr id="row_0_0_0_0_"><td class="entry"><span style="width:64px;display:inline-block;">&#160;</span><span class="icondoc"></span><a class="el" href="main_8cpp.html" target="_self">main.cpp</a></td><td class="desc">@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) </td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: 全局定义</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
<div class="textblock">这里列出了所有函数,变量,宏,枚举和类型定义等,并附带其所属的文件:</div><ul>
<li>DEFAULT_BUFLEN&#160;:&#160;<a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">main.cpp</a></li>
<li>main()&#160;:&#160;<a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main.cpp</a></li>
<li>version_h&#160;:&#160;<a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">main.cpp</a></li>
<li>version_l&#160;:&#160;<a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: 全局定义</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
&#160;<ul>
<li>DEFAULT_BUFLEN&#160;:&#160;<a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">main.cpp</a></li>
<li>version_h&#160;:&#160;<a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">main.cpp</a></li>
<li>version_l&#160;:&#160;<a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: 全局定义</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
&#160;<ul>
<li>main()&#160;:&#160;<a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD></HEAD><BODY>
<OBJECT type="text/site properties">
<param name="FrameName" value="right">
</OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="文件"><param name="Local" value="files.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="文件列表"><param name="Local" value="files.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="gitlab"><param name="Local" value="dir_06503b691a49854ec5faee5f925db041.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="windows_assist"><param name="Local" value="dir_208d139cc6923f0c37f1c403a556356e.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="TCP_client"><param name="Local" value="dir_4914f6e54a235f5de227615847bb5f71.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="main.cpp"><param name="Local" value="main_8cpp.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="DEFAULT_BUFLEN"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="version_h"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="version_l"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="main"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="ImageNumber" value="11"></OBJECT>
</UL>
</UL>
</UL>
</UL>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="全局定义"><param name="Local" value="globals.html"><param name="ImageNumber" value="11"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="全部"><param name="Local" value="globals.html"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="函数"><param name="Local" value="globals_func.html"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="宏定义"><param name="Local" value="globals_defs.html"><param name="ImageNumber" value="11"></OBJECT>
</UL>
</UL>
</UL>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD></HEAD><BODY>
<OBJECT type="text/site properties">
<param name="FrameName" value="right">
</OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="Name" value="DEFAULT_BUFLEN"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="Name" value="DEFAULT_BUFLEN"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="Name" value="main"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="Name" value="version_h"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="Name" value="version_l"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="Name" value="main"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="Name" value="version_h"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="Name" value="version_l"></OBJECT>
</UL>
</BODY>
</HTML>
[OPTIONS]
Compiled file=TCP_client.chm
Compatibility=1.1
Full-text search=Yes
Contents file=index.hhc
Default Window=main
Default topic=index.html
Index file=index.hhk
Language=0x804 Chinese (PRC)
Title=TCP_client
[WINDOWS]
main="TCP_client","index.hhc","index.hhk","index.html","index.html",,,,,0x23520,,0x10387e,,,,,,,,0
[FILES]
dir_06503b691a49854ec5faee5f925db041.html
dir_208d139cc6923f0c37f1c403a556356e.html
dir_4914f6e54a235f5de227615847bb5f71.html
files.html
globals.html
globals_defs.html
globals_func.html
index.html
main_8cpp.html
bc_s.png
bdwn.png
closed.png
nav_f.png
nav_h.png
open.png
sync_off.png
sync_on.png
tab_a.png
tab_b.png
tab_h.png
tab_s.png
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: 首页</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">TCP_client 文档</div></div>
</div><!--header-->
<div class="contents">
<ul><li><a href="index.html"><span>首页</span></a>
</li><li><a href="files.html"><span>文件</span></a>
<ul><li><a href="files.html"><span>文件列表</span></a>
</li><li><a href="globals.html"><span>全局定义</span></a>
</li></ul>
</li></ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_client: D:/gitlab/windows_assist/TCP_client/main.cpp 文件参考</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="doxygen.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">TCP_client<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li><li class="navelem"><a class="el" href="dir_4914f6e54a235f5de227615847bb5f71.html">TCP_client</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#define-members">宏定义</a> &#124;
<a href="#func-members">函数</a> </div>
<div class="headertitle"><div class="title">main.cpp 文件参考</div></div>
</div><!--header-->
<div class="contents">
<p>@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>})
<a href="#details">更多...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;WinSock2.h&gt;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
宏定义</h2></td></tr>
<tr class="memitem:a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">version_h</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf4ac85ba8f9ca065ae8c791ce6b20a5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">version_l</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:abf4ac85ba8f9ca065ae8c791ce6b20a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5261516a174b035b084a9ae06dc85730"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">DEFAULT_BUFLEN</a>&#160;&#160;&#160;512</td></tr>
<tr class="separator:a5261516a174b035b084a9ae06dc85730"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p >@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) </p>
<dl class="section version"><dt>版本</dt><dd>1.0 </dd></dl>
<dl class="section date"><dt>日期</dt><dd>2021-10-25</dd></dl>
<dl class="section copyright"><dt>版权所有</dt><dd>Copyright (c) 2021 linkor</dd></dl>
<dl class="section user"><dt>修改日志:</dt><dd><table class="doxtable">
<tr>
<th>Date </th><th>Version </th><th>Author </th><th>Description </th></tr>
<tr>
<td>2021-10-25 </td><td>1.0 </td><td>zengrx </td><td>内容 </td></tr>
</table>
</dd></dl>
</div><h2 class="groupheader">宏定义说明</h2>
<a id="a5261516a174b035b084a9ae06dc85730" name="a5261516a174b035b084a9ae06dc85730"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5261516a174b035b084a9ae06dc85730">&#9670;&nbsp;</a></span>DEFAULT_BUFLEN</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define DEFAULT_BUFLEN&#160;&#160;&#160;512</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a7e0bfb46ff08ff9ab0f50bbb87c0c0e8" name="a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">&#9670;&nbsp;</a></span>version_h</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define version_h&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="abf4ac85ba8f9ca065ae8c791ce6b20a5" name="abf4ac85ba8f9ca065ae8c791ce6b20a5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abf4ac85ba8f9ca065ae8c791ce6b20a5">&#9670;&nbsp;</a></span>version_l</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define version_l&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">函数说明</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p >1.初始化套接字库</p>
<p >高位字节指定次要版本号;低位字节指定主版本号。</p>
<p >确认WinSock DLL支持2.2,如果DLL支持更高版本,它依然返回2.2</p>
<p >2.创建套接字</p>
<p >address.sin_family 用于传输地址,他的成员始终设置为 AF_INET.</p>
<p >该语句用在服务器端,表示监听所有的客户端连接。INADDR_ANY:转换过来就是0.0.0.0,泛指本机的意思,也就是表示本机的所有IP</p>
<p >定义传输协议端口号</p>
<p >申请套接字</p>
<p >3.绑定套接字到本地的某个地址和端口</p>
<p >4.进行会话</p>
<p >5.关闭套接字</p>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
/**
* @file main.cpp
* @brief
* @zengrx {zengrx} ({757876947@qq.com})
* @version 1.0
* @date 2021-10-25
*
* @copyright Copyright (c) 2021 linkor
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-10-25 <td>1.0 <td>zengrx <td>内容
* </table>
*/
#include <stdio.h>
#include <WinSock2.h>
#define version_h 2
#define version_l 2
#define DEFAULT_BUFLEN 512
int main()
{
/**
* @brief 1.初始化套接字库
*/
///高位字节指定次要版本号;低位字节指定主版本号。
WORD wVersionRequested = MAKEWORD(version_h, version_l);
WSADATA wsaData;
int error = WSAStartup(wVersionRequested, &wsaData);
if (errno != 0)
{
printf("Cant initiates use of the Winsock DLL by a process!\n");
return 1;
}
///确认WinSock DLL支持2.2,如果DLL支持更高版本,它依然返回2.2
if (LOBYTE(wsaData.wVersion) != version_l ||
HIBYTE(wsaData.wVersion) != version_h)
{
/* 找不到可用的WinSock DLL */
printf("could not find a usable WinSock DLL!\n");
WSACleanup();
return 1;
}
/**
* @brief 2.创建套接字
*/
SOCKADDR_IN server_address;
///address.sin_family 用于传输地址,他的成员始终设置为 AF_INET.
server_address.sin_family = AF_INET;
///该语句用在服务器端,表示监听所有的客户端连接。INADDR_ANY:转换过来就是0.0.0.0,泛指本机的意思,也就是表示本机的所有IP
server_address.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
///定义传输协议端口号
server_address.sin_port = htons(5000);
///申请套接字
SOCKET socket_server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (INVALID_SOCKET == socket_server)
{
wprintf(L"socket function failed with error: %ld\n", WSAGetLastError());
getchar();
WSACleanup();
return 1;
}
/**
* @brief 3.绑定套接字到本地的某个地址和端口
*/
if(SOCKET_ERROR==connect(socket_server, (SOCKADDR *)&server_address, sizeof(server_address)))
{
wprintf(L"connect function failed with error: %ld\n", WSAGetLastError());
getchar();
closesocket(socket_server);
WSACleanup();
return 1;
}
wprintf(L"Connected to server.\n");
/**
* @brief 4.进行会话
*/
int recv_ret;
int send_ret;
char send_buff[DEFAULT_BUFLEN] ={0};
char recv_buff[DEFAULT_BUFLEN] = {0};
while (1)
{
printf("You send:");
gets(send_buff);
send_ret = send(socket_server, send_buff,DEFAULT_BUFLEN, 0);
if (SOCKET_ERROR == send_ret)
{
wprintf(L"send failed with error: %d\n", WSAGetLastError());
getchar();
closesocket(socket_server);
WSACleanup();
return 1;
}
int ret = recv(socket_server, recv_buff, DEFAULT_BUFLEN, 0);
if (ret > 0)
printf("Receive from Server: %s\n", recv_buff);
else
{
if (0 == ret)
{
printf("Connection closed\n");
break;
}
else
{
printf("recv failed: %d\n", WSAGetLastError());
getchar();
closesocket(socket_server);
WSACleanup();
return 1;
}
}
}
/**
* @brief 5.关闭套接字
*/
if (SOCKET_ERROR == closesocket(socket_server))
{
wprintf(L"closesocket function failed with error %d\n", WSAGetLastError());
getchar();
WSACleanup();
return 1;
}
WSACleanup();
return 0;
}
Build
/Debug/*
*.log
/release/*
/Release/*
/.vs/*
/x64/*
/x86/*
cmake_minimum_required(VERSION 3.0.0)
project(helloword VERSION 0.1.0)
#reset output path
set ( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin )
set ( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib )
include(CTest)
enable_testing()
#set include file
include_directories (./inc)
#set source file
aux_source_directory ( . DIR_USR_SOURCE )
aux_source_directory ( ./src DIR_USR_SOURCE )
# find_library(WSOCK32_LIBRARY wsock32)
# find_library(WS2_32_LIBRARY ws2_32)
# add_executable(helloword main.cpp)
add_executable ( ${CMAKE_PROJECT_NAME} ${DIR_USR_SOURCE} )
if(WIN32)
target_link_libraries(${CMAKE_PROJECT_NAME} wsock32 ws2_32)
endif()
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: D:/gitlab 目录参考</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">gitlab 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="subdirs" name="subdirs"></a>
目录</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">目录 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: D:/gitlab/windows_assist 目录参考</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">windows_assist 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="subdirs" name="subdirs"></a>
目录</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">目录 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="dir_ce5b672c9b31ec079806d47d8a675b57.html">TCP_server</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: D:/gitlab/windows_assist/TCP_server 目录参考</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li><li class="navelem"><a class="el" href="dir_ce5b672c9b31ec079806d47d8a675b57.html">TCP_server</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">TCP_server 目录参考</div></div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="files" name="files"></a>
文件</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">文件 &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html">main.cpp</a></td></tr>
<tr class="memdesc:main_8cpp"><td class="mdescLeft">&#160;</td><td class="mdescRight">@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
/*
@licstart The following is the entire license notice for the JavaScript code in this file.
The MIT License (MIT)
Copyright (C) 1997-2020 by Dimitri van Heesch
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@licend The above is the entire license notice for the JavaScript code in this file
*/
function toggleVisibility(linkObj)
{
var base = $(linkObj).attr('id');
var summary = $('#'+base+'-summary');
var content = $('#'+base+'-content');
var trigger = $('#'+base+'-trigger');
var src=$(trigger).attr('src');
if (content.is(':visible')===true) {
content.hide();
summary.show();
$(linkObj).addClass('closed').removeClass('opened');
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
content.show();
summary.hide();
$(linkObj).removeClass('closed').addClass('opened');
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
}
return false;
}
function updateStripes()
{
$('table.directory tr').
removeClass('even').filter(':visible:even').addClass('even');
}
function toggleLevel(level)
{
$('table.directory tr').each(function() {
var l = this.id.split('_').length-1;
var i = $('#img'+this.id.substring(3));
var a = $('#arr'+this.id.substring(3));
if (l<level+1) {
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
a.html('&#9660;');
$(this).show();
} else if (l==level+1) {
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
a.html('&#9658;');
$(this).show();
} else {
$(this).hide();
}
});
updateStripes();
}
function toggleFolder(id)
{
// the clicked row
var currentRow = $('#row_'+id);
// all rows after the clicked row
var rows = currentRow.nextAll("tr");
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
// only match elements AFTER this one (can't hide elements before)
var childRows = rows.filter(function() { return this.id.match(re); });
// first row is visible we are HIDING
if (childRows.filter(':first').is(':visible')===true) {
// replace down arrow by right arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
currentRowSpans.filter(".arrow").html('&#9658;');
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
} else { // we are SHOWING
// replace right arrow by down arrow for current row
var currentRowSpans = currentRow.find("span");
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
currentRowSpans.filter(".arrow").html('&#9660;');
// replace down arrows by right arrows for child rows
var childRowsSpans = childRows.find("span");
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
childRowsSpans.filter(".arrow").html('&#9658;');
childRows.show(); //show all children
}
updateStripes();
}
function toggleInherit(id)
{
var rows = $('tr.inherit.'+id);
var img = $('tr.inherit_header.'+id+' img');
var src = $(img).attr('src');
if (rows.filter(':first').is(':visible')===true) {
rows.css('display','none');
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
} else {
rows.css('display','table-row'); // using show() causes jump in firefox
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
}
}
/* @license-end */
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: 文件列表</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">文件列表</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock">这里列出了所有文件,并附带简要说明:</div><div class="directory">
<div class="levels">[详情级别 <span onclick="javascript:toggleLevel(1);">1</span><span onclick="javascript:toggleLevel(2);">2</span><span onclick="javascript:toggleLevel(3);">3</span><span onclick="javascript:toggleLevel(4);">4</span>]</div><table class="directory">
<tr id="row_0_" class="even"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_0_" class="arrow" onclick="toggleFolder('0_')">&#9660;</span><span id="img_0_" class="iconfopen" onclick="toggleFolder('0_')">&#160;</span><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html" target="_self">gitlab</a></td><td class="desc"></td></tr>
<tr id="row_0_0_"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span id="arr_0_0_" class="arrow" onclick="toggleFolder('0_0_')">&#9660;</span><span id="img_0_0_" class="iconfopen" onclick="toggleFolder('0_0_')">&#160;</span><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html" target="_self">windows_assist</a></td><td class="desc"></td></tr>
<tr id="row_0_0_0_" class="even"><td class="entry"><span style="width:32px;display:inline-block;">&#160;</span><span id="arr_0_0_0_" class="arrow" onclick="toggleFolder('0_0_0_')">&#9660;</span><span id="img_0_0_0_" class="iconfopen" onclick="toggleFolder('0_0_0_')">&#160;</span><a class="el" href="dir_ce5b672c9b31ec079806d47d8a675b57.html" target="_self">TCP_server</a></td><td class="desc"></td></tr>
<tr id="row_0_0_0_0_"><td class="entry"><span style="width:64px;display:inline-block;">&#160;</span><span class="icondoc"></span><a class="el" href="main_8cpp.html" target="_self">main.cpp</a></td><td class="desc">@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) </td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: 全局定义</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
<div class="textblock">这里列出了所有函数,变量,宏,枚举和类型定义等,并附带其所属的文件:</div><ul>
<li>DEFAULT_BUFLEN&#160;:&#160;<a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">main.cpp</a></li>
<li>main()&#160;:&#160;<a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main.cpp</a></li>
<li>version_h&#160;:&#160;<a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">main.cpp</a></li>
<li>version_l&#160;:&#160;<a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: 全局定义</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
&#160;<ul>
<li>DEFAULT_BUFLEN&#160;:&#160;<a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">main.cpp</a></li>
<li>version_h&#160;:&#160;<a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">main.cpp</a></li>
<li>version_l&#160;:&#160;<a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: 全局定义</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="contents">
&#160;<ul>
<li>main()&#160;:&#160;<a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main.cpp</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD></HEAD><BODY>
<OBJECT type="text/site properties">
<param name="FrameName" value="right">
</OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="文件"><param name="Local" value="files.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="文件列表"><param name="Local" value="files.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="gitlab"><param name="Local" value="dir_06503b691a49854ec5faee5f925db041.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="windows_assist"><param name="Local" value="dir_208d139cc6923f0c37f1c403a556356e.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="TCP_server"><param name="Local" value="dir_ce5b672c9b31ec079806d47d8a675b57.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="main.cpp"><param name="Local" value="main_8cpp.html"><param name="ImageNumber" value="1"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="DEFAULT_BUFLEN"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="version_h"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="version_l"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="main"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="ImageNumber" value="11"></OBJECT>
</UL>
</UL>
</UL>
</UL>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="全局定义"><param name="Local" value="globals.html"><param name="ImageNumber" value="11"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Name" value="全部"><param name="Local" value="globals.html"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="函数"><param name="Local" value="globals_func.html"><param name="ImageNumber" value="11"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Name" value="宏定义"><param name="Local" value="globals_defs.html"><param name="ImageNumber" value="11"></OBJECT>
</UL>
</UL>
</UL>
</BODY>
</HTML>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML><HEAD></HEAD><BODY>
<OBJECT type="text/site properties">
<param name="FrameName" value="right">
</OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="Name" value="DEFAULT_BUFLEN"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a5261516a174b035b084a9ae06dc85730"><param name="Name" value="DEFAULT_BUFLEN"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="Name" value="main"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="Name" value="version_h"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html"><param name="Name" value="main.cpp"></OBJECT>
<UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="Name" value="version_l"></OBJECT>
</UL>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4"><param name="Name" value="main"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><param name="Name" value="version_h"></OBJECT>
<LI><OBJECT type="text/sitemap"><param name="Local" value="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5"><param name="Name" value="version_l"></OBJECT>
</UL>
</BODY>
</HTML>
[OPTIONS]
Compiled file=TCP_client.chm
Compatibility=1.1
Full-text search=Yes
Contents file=index.hhc
Default Window=main
Default topic=index.html
Index file=index.hhk
Language=0x804 Chinese (PRC)
Title=TCP_server
[WINDOWS]
main="TCP_server","index.hhc","index.hhk","index.html","index.html",,,,,0x23520,,0x10387e,,,,,,,,0
[FILES]
dir_06503b691a49854ec5faee5f925db041.html
dir_208d139cc6923f0c37f1c403a556356e.html
dir_ce5b672c9b31ec079806d47d8a675b57.html
files.html
globals.html
globals_defs.html
globals_func.html
index.html
main_8cpp.html
bc_s.png
bdwn.png
closed.png
nav_f.png
nav_h.png
open.png
sync_off.png
sync_on.png
tab_a.png
tab_b.png
tab_h.png
tab_s.png
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: 首页</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">TCP_server 文档</div></div>
</div><!--header-->
<div class="contents">
<ul><li><a href="index.html"><span>首页</span></a>
</li><li><a href="files.html"><span>文件</span></a>
<ul><li><a href="files.html"><span>文件列表</span></a>
</li><li><a href="globals.html"><span>全局定义</span></a>
</li></ul>
</li></ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>TCP_server: D:/gitlab/windows_assist/TCP_server/main.cpp 文件参考</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="doxygen.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">TCP_server<span id="projectnumber">&#160;1.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.2 -->
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_06503b691a49854ec5faee5f925db041.html">gitlab</a></li><li class="navelem"><a class="el" href="dir_208d139cc6923f0c37f1c403a556356e.html">windows_assist</a></li><li class="navelem"><a class="el" href="dir_ce5b672c9b31ec079806d47d8a675b57.html">TCP_server</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#define-members">宏定义</a> &#124;
<a href="#func-members">函数</a> </div>
<div class="headertitle"><div class="title">main.cpp 文件参考</div></div>
</div><!--header-->
<div class="contents">
<p>@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>})
<a href="#details">更多...</a></p>
<div class="textblock"><code>#include &lt;stdio.h&gt;</code><br />
<code>#include &lt;WinSock2.h&gt;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="define-members" name="define-members"></a>
宏定义</h2></td></tr>
<tr class="memitem:a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">version_h</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:abf4ac85ba8f9ca065ae8c791ce6b20a5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#abf4ac85ba8f9ca065ae8c791ce6b20a5">version_l</a>&#160;&#160;&#160;2</td></tr>
<tr class="separator:abf4ac85ba8f9ca065ae8c791ce6b20a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5261516a174b035b084a9ae06dc85730"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#a5261516a174b035b084a9ae06dc85730">DEFAULT_BUFLEN</a>&#160;&#160;&#160;512</td></tr>
<tr class="separator:a5261516a174b035b084a9ae06dc85730"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="main_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4">main</a> ()</td></tr>
<tr class="separator:ae66f6b31b5ad750f1fe042a706a4e3d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><p >@zengrx {zengrx} ({<a href="#" onclick="location.href='mai'+'lto:'+'757'+'87'+'694'+'7@'+'qq.'+'co'+'m'; return false;">75787<span style="display: none;">.nosp@m.</span>6947<span style="display: none;">.nosp@m.</span>@qq.c<span style="display: none;">.nosp@m.</span>om</a>}) </p>
<dl class="section version"><dt>版本</dt><dd>1.0 </dd></dl>
<dl class="section date"><dt>日期</dt><dd>2021-10-25</dd></dl>
<dl class="section copyright"><dt>版权所有</dt><dd>Copyright (c) 2021 linkor</dd></dl>
<dl class="section user"><dt>修改日志:</dt><dd><table class="doxtable">
<tr>
<th>Date </th><th>Version </th><th>Author </th><th>Description </th></tr>
<tr>
<td>2021-10-25 </td><td>1.0 </td><td>zengrx </td><td>TCP_server注释 </td></tr>
</table>
</dd></dl>
</div><h2 class="groupheader">宏定义说明</h2>
<a id="a5261516a174b035b084a9ae06dc85730" name="a5261516a174b035b084a9ae06dc85730"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5261516a174b035b084a9ae06dc85730">&#9670;&nbsp;</a></span>DEFAULT_BUFLEN</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define DEFAULT_BUFLEN&#160;&#160;&#160;512</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="a7e0bfb46ff08ff9ab0f50bbb87c0c0e8" name="a7e0bfb46ff08ff9ab0f50bbb87c0c0e8"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7e0bfb46ff08ff9ab0f50bbb87c0c0e8">&#9670;&nbsp;</a></span>version_h</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define version_h&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<a id="abf4ac85ba8f9ca065ae8c791ce6b20a5" name="abf4ac85ba8f9ca065ae8c791ce6b20a5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#abf4ac85ba8f9ca065ae8c791ce6b20a5">&#9670;&nbsp;</a></span>version_l</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">#define version_l&#160;&#160;&#160;2</td>
</tr>
</table>
</div><div class="memdoc">
</div>
</div>
<h2 class="groupheader">函数说明</h2>
<a id="ae66f6b31b5ad750f1fe042a706a4e3d4" name="ae66f6b31b5ad750f1fe042a706a4e3d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae66f6b31b5ad750f1fe042a706a4e3d4">&#9670;&nbsp;</a></span>main()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int main </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p >1.初始化套接字库</p>
<p >高位字节指定次要版本号;低位字节指定主版本号。</p>
<p >确认WinSock DLL支持2.2,如果DLL支持更高版本,它依然返回2.2</p>
<p >找不到可用的WinSock DLL</p>
<p >2.创建套接字</p>
<p >address.sin_family 用于传输地址,他的成员始终设置为 AF_INET.</p>
<p >该语句用在服务器端,表示监听所有的客户端连接。INADDR_ANY:转换过来就是0.0.0.0,泛指本机的意思,也就是表示本机的所有IP</p>
<p >定义传输协议端口号</p>
<p >申请套接字</p>
<p >3.绑定套接字到本地的某个地址和端口</p>
<p >4.监听客户端</p>
<p >5.接受客户端连接</p>
<p >6.进行会话</p>
<p >7.关闭套接字</p>
</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.2
</small></address>
</body>
</html>
/**
* @file main.cpp
* @brief
* @zengrx {zengrx} ({757876947@qq.com})
* @version 1.0
* @date 2021-10-25
*
* @copyright Copyright (c) 2021 linkor
*
* @par 修改日志:
* <table>
* <tr><th>Date <th>Version <th>Author <th>Description
* <tr><td>2021-10-25 <td>1.0 <td>zengrx <td>TCP_server注释
* </table>
*/
#include <stdio.h>
#include <WinSock2.h>
#define version_h 2
#define version_l 2
#define DEFAULT_BUFLEN 512
int main()
{
/**
* @brief 1.初始化套接字库
*/
///高位字节指定次要版本号;低位字节指定主版本号。
WORD wVersionRequested = MAKEWORD(version_h, version_l);
WSADATA wsaData;
int error = WSAStartup(wVersionRequested, &wsaData);
if (errno != 0)
{
printf("Cant initiates use of the Winsock DLL by a process!\n");
return 1;
}
///确认WinSock DLL支持2.2,如果DLL支持更高版本,它依然返回2.2
if (LOBYTE(wsaData.wVersion) != version_l ||
HIBYTE(wsaData.wVersion) != version_h)
{
///找不到可用的WinSock DLL
printf("could not find a usable WinSock DLL!\n");
WSACleanup();
return 1;
}
/**
* @brief 2.创建套接字
*/
SOCKADDR_IN server_address;
///address.sin_family 用于传输地址,他的成员始终设置为 AF_INET.
server_address.sin_family = AF_INET;
///该语句用在服务器端,表示监听所有的客户端连接。INADDR_ANY:转换过来就是0.0.0.0,泛指本机的意思,也就是表示本机的所有IP
server_address.sin_addr.S_un.S_addr = htonl(INADDR_ANY);
///定义传输协议端口号
server_address.sin_port = htons(5000);
///申请套接字
SOCKET socket_server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (INVALID_SOCKET == socket_server)
{
wprintf(L"socket function failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
/**
* @brief 3.绑定套接字到本地的某个地址和端口
*/
if (SOCKET_ERROR == bind(socket_server, (SOCKADDR *)&server_address, sizeof(server_address)))
{
wprintf(L"bind failed with error %u\n", WSAGetLastError());
closesocket(socket_server);
WSACleanup();
return 1;
}
wprintf(L"bind returned success\n");
/**
* @brief 4.监听客户端
*/
if (SOCKET_ERROR == listen(socket_server, 1))
wprintf(L"listen function failed with error: %d\n", WSAGetLastError());
wprintf(L"Listening on socket...\n");
/**
* @brief 5.接受客户端连接
*/
SOCKADDR_IN client_address;
int address_length=sizeof(client_address);
SOCKET socket_client = accept(socket_server, (SOCKADDR *)&client_address, &address_length);
if (INVALID_SOCKET == socket_client)
wprintf(L"accept failed with error: %ld\n", WSAGetLastError());
wprintf(L"connect client success\n");
/**
* @brief 6.进行会话
*/
char send_buff[DEFAULT_BUFLEN] = "I receive your message!";
char recv_buff[DEFAULT_BUFLEN] = {0};
while (1)
{
int ret = recv(socket_client, recv_buff, DEFAULT_BUFLEN, 0);
if (ret > 0)
printf("Receive from Client: %s\n", recv_buff);
else
{
if (0 == ret)
{
printf("Connection closed\n");
break;
}
else
{
printf("recv failed: %d\n", WSAGetLastError());
closesocket(socket_client);
closesocket(socket_server);
WSACleanup();
return 1;
}
}
ret = send(socket_client, send_buff,DEFAULT_BUFLEN, 0);
if (SOCKET_ERROR == ret)
{
wprintf(L"send failed with error: %d\n", WSAGetLastError());
closesocket(socket_client);
closesocket(socket_server);
WSACleanup();
return 1;
}
}
/**
* @brief 7.关闭套接字
*/
if (SOCKET_ERROR == closesocket(socket_client))
{
wprintf(L"closesocket function failed with error %d\n", WSAGetLastError());
WSACleanup();
return 1;
}
if (SOCKET_ERROR == closesocket(socket_server))
{
wprintf(L"closesocket function failed with error %d\n", WSAGetLastError());
WSACleanup();
return 1;
}
WSACleanup();
return 0;
}
Build
/Debug/*
*.log
/release/*
/Release/*
/.vs/*
/x64/*
/x86/*
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
}
\ No newline at end of file
cmake_minimum_required(VERSION 3.0.0)
project(helloword VERSION 0.1.0)
#reset output path
set ( EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin )
set ( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib )
include(CTest)
enable_testing()
#set include file
include_directories (./inc)
#set source file
aux_source_directory ( . DIR_USR_SOURCE )
aux_source_directory ( ./src DIR_USR_SOURCE )
# add_executable(helloword main.cpp)
add_executable ( ${CMAKE_PROJECT_NAME} ${DIR_USR_SOURCE} )
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
\ No newline at end of file
#ifndef _WZSERIALPORT_H
#define _WZSERIALPORT_H
#include <iostream>
using namespace std;
/*
作者:欧阳伟
日期:2017-12-14
类名:WZSerialPort
用途:串口读写
示例:
WZSerialPort w;
if(w.open("COM1",9600,0,8,1))
{
w.send("helloworld",10);
char buf[1024];
w.receive(buf,1024);
}
*/
class WZSerialPort
{
public:
WZSerialPort();
~WZSerialPort();
// 打开串口,成功返回true,失败返回false
// portname(串口名): 在Windows下是"COM1""COM2"等,在Linux下是"/dev/ttyS1"等
// baudrate(波特率): 9600、19200、38400、43000、56000、57600、115200
// parity(校验位): 0为无校验,1为奇校验,2为偶校验,3为标记校验
// databit(数据位): 4-8,通常为8位
// stopbit(停止位): 1为1位停止位,2为2位停止位,3为1.5位停止位
// synchronizable(同步、异步): 0为异步,1为同步
bool open(const char* portname, int baudrate=115200, char parity=0, char databit=8, char stopbit=1, char synchronizeflag=0);
//关闭串口,参数待定
void close();
//发送数据或写数据,成功返回发送数据长度,失败返回0
int send(string dat);
//接受数据或读数据,成功返回读取实际数据的长度,失败返回0
string receive();
private:
int pHandle[16];
char synchronizeflag;
};
#endif
\ No newline at end of file
#include "WZSerialPort.h"
#include<iostream>
using namespace std;
int main()
{
WZSerialPort w;
if (w.open("COM3", 9600, 0, 8, 1, 1))
{
string str = "helloworsdasadfgsdjhjshdfgvhjhjzxvjzhhcsdugdczxhjczsdhdhxghdgysdhhhhjjhdjhfvvld";
w.send(str);
}
while (true)
{
cout << w.receive().c_str();
}
// 原代码
// cout << w.receive().c_str();
// // w.close();
// }
// while (true)
// {
// }
return 0;
}
\ No newline at end of file
#include "WZSerialPort.h"
#include <stdio.h>
#include <string.h>
#include <WinSock2.h>
#include <windows.h>
#include<iostream>
using namespace std;
WZSerialPort::WZSerialPort()
{
}
WZSerialPort::~WZSerialPort()
{
}
bool WZSerialPort::open(const char* portname,
int baudrate,
char parity,
char databit,
char stopbit,
char synchronizeflag)
{
this->synchronizeflag = synchronizeflag;
HANDLE hCom = NULL;
if (this->synchronizeflag)
{
//同步方式
hCom = CreateFileA(portname, //串口名
GENERIC_READ | GENERIC_WRITE, //支持读写
0, //独占方式,串口不支持共享
NULL,//安全属性指针,默认值为NULL
OPEN_EXISTING, //打开现有的串口文件
0, //0:同步方式,FILE_FLAG_OVERLAPPED:异步方式
NULL);//用于复制文件句柄,默认值为NULL,对串口而言该参数必须置为NULL
}
else
{
//异步方式
hCom = CreateFileA(portname, //串口名
GENERIC_READ | GENERIC_WRITE, //支持读写
0, //独占方式,串口不支持共享
NULL,//安全属性指针,默认值为NULL
OPEN_EXISTING, //打开现有的串口文件
FILE_FLAG_OVERLAPPED, //0:同步方式,FILE_FLAG_OVERLAPPED:异步方式
NULL);//用于复制文件句柄,默认值为NULL,对串口而言该参数必须置为NULL
}
if(hCom == (HANDLE)-1)
{
return false;
}
//配置缓冲区大小
if(! SetupComm(hCom,1024, 1024))
{
return false;
}
// 配置参数
DCB p;
memset(&p, 0, sizeof(p));
p.DCBlength = sizeof(p);
p.BaudRate = baudrate; // 波特率
p.ByteSize = databit; // 数据位
switch (parity) //校验位
{
case 0:
p.Parity = NOPARITY; //无校验
break;
case 1:
p.Parity = ODDPARITY; //奇校验
break;
case 2:
p.Parity = EVENPARITY; //偶校验
break;
case 3:
p.Parity = MARKPARITY; //标记校验
break;
}
switch(stopbit) //停止位
{
case 1:
p.StopBits = ONESTOPBIT; //1位停止位
break;
case 2:
p.StopBits = TWOSTOPBITS; //2位停止位
break;
case 3:
p.StopBits = ONE5STOPBITS; //1.5位停止位
break;
}
if(! SetCommState(hCom, &p))
{
// 设置参数失败
return false;
}
//超时处理,单位:毫秒
//总超时=时间系数×读或写的字符数+时间常量
COMMTIMEOUTS TimeOuts;
TimeOuts.ReadIntervalTimeout = 1000; //读间隔超时
TimeOuts.ReadTotalTimeoutMultiplier = 500; //读时间系数
TimeOuts.ReadTotalTimeoutConstant = 5000; //读时间常量
TimeOuts.WriteTotalTimeoutMultiplier = 500; // 写时间系数
TimeOuts.WriteTotalTimeoutConstant = 2000; //写时间常量
SetCommTimeouts(hCom,&TimeOuts);
PurgeComm(hCom,PURGE_TXCLEAR|PURGE_RXCLEAR);//清空串口缓冲区
memcpy(pHandle, &hCom, sizeof(hCom));// 保存句柄
return true;
}
void WZSerialPort::close()
{
HANDLE hCom = *(HANDLE*)pHandle;
CloseHandle(hCom);
}
int WZSerialPort::send(string dat)
{
HANDLE hCom = *(HANDLE*)pHandle;
if (this->synchronizeflag)
{
// 同步方式
DWORD dwBytesWrite = dat.length(); //成功写入的数据字节数
BOOL bWriteStat = WriteFile(hCom, //串口句柄
(char*)dat.c_str(), //数据首地址
dwBytesWrite, //要发送的数据字节数
&dwBytesWrite, //DWORD*,用来接收返回成功发送的数据字节数
NULL); //NULL为同步发送,OVERLAPPED*为异步发送
if (!bWriteStat)
{
return 0;
}
return dwBytesWrite;
}
else
{
//异步方式
DWORD dwBytesWrite = dat.length(); //成功写入的数据字节数
DWORD dwErrorFlags; //错误标志
COMSTAT comStat; //通讯状态
OVERLAPPED m_osWrite; //异步输入输出结构体
//创建一个用于OVERLAPPED的事件处理,不会真正用到,但系统要求这么做
memset(&m_osWrite, 0, sizeof(m_osWrite));
m_osWrite.hEvent = CreateEvent(NULL, TRUE, FALSE, "WriteEvent");
ClearCommError(hCom, &dwErrorFlags, &comStat); //清除通讯错误,获得设备当前状态
BOOL bWriteStat = WriteFile(hCom, //串口句柄
(char*)dat.c_str(), //数据首地址
dwBytesWrite, //要发送的数据字节数
&dwBytesWrite, //DWORD*,用来接收返回成功发送的数据字节数
&m_osWrite); //NULL为同步发送,OVERLAPPED*为异步发送
if (!bWriteStat)
{
if (GetLastError() == ERROR_IO_PENDING) //如果串口正在写入
{
WaitForSingleObject(m_osWrite.hEvent, 1000); //等待写入事件1秒钟
}
else
{
ClearCommError(hCom, &dwErrorFlags, &comStat); //清除通讯错误
CloseHandle(m_osWrite.hEvent); //关闭并释放hEvent内存
return 0;
}
}
return dwBytesWrite;
}
}
string WZSerialPort::receive()
{
HANDLE hCom = *(HANDLE*)pHandle;
string rec_str="";
char buf[1024];
if (this->synchronizeflag)
{
//同步方式
DWORD wCount = 1024; //成功读取的数据字节数
BOOL bReadStat = ReadFile(hCom, //串口句柄
buf, //数据首地址
wCount, //要读取的数据最大字节数
&wCount, //DWORD*,用来接收返回成功读取的数据字节数
NULL); //NULL为同步发送,OVERLAPPED*为异步发送
for (int i = 0; i < 1024; i++)
{
if (buf[i] != -52)
rec_str += buf[i];
else
break;
}
return rec_str;
}
else
{
//异步方式
DWORD wCount = 1024; //成功读取的数据字节数
DWORD dwErrorFlags; //错误标志
COMSTAT comStat; //通讯状态
OVERLAPPED m_osRead; //异步输入输出结构体
//创建一个用于OVERLAPPED的事件处理,不会真正用到,但系统要求这么做
memset(&m_osRead, 0, sizeof(m_osRead));
m_osRead.hEvent = CreateEvent(NULL, TRUE, FALSE, "ReadEvent");
ClearCommError(hCom, &dwErrorFlags, &comStat); //清除通讯错误,获得设备当前状态
if (!comStat.cbInQue)return 0; //如果输入缓冲区字节数为0,则返回false
//std::cout << comStat.cbInQue << std::endl;
BOOL bReadStat = ReadFile(hCom, //串口句柄
buf, //数据首地址
wCount, //要读取的数据最大字节数
&wCount, //DWORD*,用来接收返回成功读取的数据字节数
&m_osRead); //NULL为同步发送,OVERLAPPED*为异步发送
if (!bReadStat)
{
if (GetLastError() == ERROR_IO_PENDING) //如果串口正在读取中
{
//GetOverlappedResult函数的最后一个参数设为TRUE
//函数会一直等待,直到读操作完成或由于错误而返回
GetOverlappedResult(hCom, &m_osRead, &wCount, TRUE);
}
else
{
ClearCommError(hCom, &dwErrorFlags, &comStat); //清除通讯错误
CloseHandle(m_osRead.hEvent); //关闭并释放hEvent的内存
return 0;
}
}
for (int i = 0;i<1024; i++)
{
if (buf[i]!=-52)
rec_str += buf[i];
else
break;
}
return rec_str;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment