2 Star 0 Fork 0

白一梓/socket_close

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README
MIT

这是博客《小议socket挥手》的配套代码

其中文件夹c下配套c代码,文件夹java下是java代码。

c文件夹下的client_test是socket客户端代码,可以在windows vs2010或者linux下编译通过;socket_server是socket的服务器端代码,目前仅仅只能通过vs2010编译。

java文件夹下是一个eclipse工程,里面仅仅包含两个java类,一个处理服务器端、一个处理客户端。

博客文中代码片段出处:

  1. 代码片段1.1出自 c/client_test/client.c
  2. 代码片段1.2出自c/client_test/common_socket.h
  3. 代码片段1.3出自c/socket_server/server.cpp
  4. 代码片段2.1、2.2出自c/client_test/common_socket.c
  5. 代码片段3.1出自java/src/Client.java

对于socket关闭的主动发起者,c代码中发起者为客户端(c/client_test/client.c),java代码中发起者为服务器端(java/src/Server.java),具体可以参考相应代码。

查看socket的挥手数据包,推荐使用wireshark进行抓包,注意使用两台机器进行测试,如果没有机器,可以使用虚拟机,这时候虚拟机的网络连接方式需要使用桥接或者host only,以保证客户端和服务器端的IP是不一样的,因为wireshark不能抓取127.0.0.1的回路数据包。抓取的时候可以使用tcp.port == 9090这个filter,因为示例代码中使用的tcp监听端口为9090,这样能够仅仅抓取到于代码相关的数据包,防止出现其他无用数据包的干扰。

The MIT License (MIT) Copyright (c) 2014 白衣子 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.

About

博客http://blog.csdn.net/yunnysunny/article/details/18994927 示例代码 expand collapse
C
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/yunnysunny/socket_close.git
git@gitee.com:yunnysunny/socket_close.git
yunnysunny
socket_close
socket_close
master

Search

344bd9b3 5694891 D2dac590 5694891