惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - D10.天地弦

AWS IoT 消息代理 我的博客即将入驻“云栖社区”,诚邀技术同仁一同入驻。 Delphi调用java so Delphi inline编译器优化问题 [付费视频]Delphi视频Android开发使用静态库(A)和动态库(SO) DSS中间件介绍 求字符串的长度 [DiocpRPC]介绍与安装 发布一个UDP调试助手 VS2013使用rtklib中需要注意的一些问题(编译) [MyBean-插件]MyBean通用报表免费无限制版本发布 [C#-SQLite] SQLite一些奇怪的问题 [Delphi编译错误]F2084 Internal Error: U2107 Diocp截图 [DIOCP视频]-DIOCPFileServer视频 DIOCP 运作核心探密 DIOCP-DIOCPv5的处理能力 DIOCP-V5发布 MyBean通用报表插件介绍
【被C折腾系列】用C调DIOCP编码客户端通信
D10.天地弦 · 2015-03-05 · via 博客园 - D10.天地弦

前几天有个朋友,说他们公司做手游,服务端用的DIOCP3里面做文件服务器,客户端用cocos-x,在调试与diocp通信时老是失败!

于是,我下载了一个Codeblocks经过几个小时的折腾,终于折腾出来了,把其中的一些心酸记录下,以便以后查阅。

1.windows下面使用socket的一些函数时,需要设置工程的选项或者工具的编译选项

[project –> build options]->[linker settings]或者[setting]->[complier]->Linker settings]中添加

F:\Tools\C\CodeBlocks\MinGW\lib\*.a 到 [link libraries]中

要不然会出现编译错误

undefined reference to `WSAStartup@8'

2.关于c中的extern和static

  百度上面有比较多的解释,

  extern 表示修饰的函数或者变量是从其他文件中引用。(extern告诉编译器这个变量或者函数在其他文件里已经被定义了)

  static 表示修饰的函数或者变量只能在本文件中使用。static还可以修饰局部变量,表示局部变量在退出函数后,该变量不可用,但是再次进入到函数时,该变量会保存之前的值。

下面为调试的截图

image

上面截图说明与服务器进行了一次通信,服务器接收特定的编码格式(Flag + CheckValue + datalen + data)

发送过去后,服务端会进行编码原样返回。

总结:

    接触一门其他语言,需要多去写代码,只有在写的过程当中才会去碰到问题,解决问题,积累被坑的经验。思路和想法有了,剩下的就是多被坑点就好了