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

推荐订阅源

GbyAI
GbyAI
J
Java Code Geeks
雷峰网
雷峰网
WordPress大学
WordPress大学
宝玉的分享
宝玉的分享
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
V
Vulnerabilities – Threatpost
S
Securelist
The Hacker News
The Hacker News
The Register - Security
The Register - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
G
Google Developers Blog
Hugging Face - Blog
Hugging Face - Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
M
MIT News - Artificial intelligence
AI
AI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Schneier on Security
Schneier on Security
N
Netflix TechBlog - Medium
T
The Blog of Author Tim Ferriss
Google DeepMind News
Google DeepMind News
Hacker News - Newest:
Hacker News - Newest: "LLM"
H
Hacker News: Front Page
博客园 - 司徒正美
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog
Microsoft Azure Blog
Microsoft Azure Blog
大猫的无限游戏
大猫的无限游戏
Security Latest
Security Latest
Engineering at Meta
Engineering at Meta
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
T
Threat Research - Cisco Blogs
U
Unit 42
V
V2EX
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
Recorded Future
Recorded Future
P
Privacy & Cybersecurity Law Blog
美团技术团队
小众软件
小众软件
F
Fortinet All Blogs

博客园 - 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)

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

总结:

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