|
[求助]如何提高程序健壮性?(发了程序,在用户机器上会出错)
经验不足,考虑不全面啦! 比如: 当你分配一块内存的时候,考虑到失败的处理么? 当你打开一个文件的时候,考虑到打不开的处理么? 当你代码中有GetMessage、PeekMessage时,考虑到消息重入么? 当你的代码中有多线程,考虑到对象的线程安全么? 当你代码中使用到锁,考虑到死锁避免么? 记住,你时刻要想着操作失败怎么办?好的程序往往出错处理占了全部代码的绝大部分! 还有就是要将测试计划做充分,当然这都是和经验水平相关的。 |
|
[求助]TCP的IOCP服务端把消息广播到客户端有什么好的方法
看来你对TCPIP协议理解有问题,TCP是不会因为接收方忙而丢包的,UDP会。 TCP协议使用超时重发和确认机制会保证数据可靠地传到另一端的。 |
|
[求助]TCP的IOCP服务端把消息广播到客户端有什么好的方法
不要在通讯线程以外直接投递发送,上一次发送不一定发送完所有数据,会导致乱序 应该为每一个会话建一个发送队列,发送完成一个完整的包,再发送下一个 给一个客户端发送数据,就是将数据包加到该会话的队列中,并且检查该客户是否有peding中的send,如果没有,启动一次发送。 在收到一个发送完成通知时,先检查上次是否发送了全部数据,如果没有,移动一下指针,继续发送,否则,发送下一个数据包(如果发送队列不空的话) iocp模型是很高效的,一个io投递是瞬时完成的,你程序的开销主要来自各种同步(锁等待),和你的构架关系很大 |
|
[求助]一段socket代码似乎有问题。高手指教下。连接成功收不到消息
WSAEventSelect 会将socket设为非阻塞模式 用非阻塞socket进行连接,一般会返回SOCKET_ERROR并且WSAGetLastError会返回WSAEWOULDBLOCK 只有在连接返回SOCKET_ERROR并且WSAGetLastError会返回WSAEWOULDBLOCK的情况下,而且通过WSAEventSelect登记了FD_CONNECT,应用程序连接成功才会得到FD_CONNECT通知 你检查connect返回值了么? 补充一句: 你这个程序用不着多线程,在连接调用后,直接进入通知等待和通知处理就行了 |
|
如何获取到checkbox那个正方形的小方块位置呢
Item的位置都知道了,作为Item一部分的那个checkbox的位置一般相对于Item是固定的,item的位置加一个偏移就可以了。 |
|
[求助]一段socket代码似乎有问题。高手指教下。连接成功收不到消息
你的程序不能保证WSAEventSelect 一定比connect先执行 |
|
如何获取到checkbox那个正方形的小方块位置呢
有可能Tree的每一个TreeItem完全是自画的,TreeItem的定位是根据Tree的各个Item可见状态以及Item所在的层次加上整个TreeView的滚动位置等信息算出来的,那样的话要想得到另一个进程的一个确定Tree的一个确定的Item的位置是相当困难的,几乎是不可能的。 |
|
如何获取到checkbox那个正方形的小方块位置呢
首先,那个Tree的句柄应该不难得到 如果那个小空件是那个tree的子窗口或者子窗口的子窗口的话,通过EnumChildWidnows应该可以得到每一个子窗口的句柄,根据句柄,你可以得到其屏幕位置、Title等,以确定是否是你想要的 如果那个小窗口根本就不是一个windows窗口,那就没辙了,Tree控件的实现千差万别,不能保证你的问题就一定能够解决 祝你好运! |
|
[求助]exe运行时,整个文件都加载到内存里吗?
The return type of LoadResource is HGLOBAL for backward compatibility, not because the function returns a handle to a global memory block. Do not pass this handle to the GlobalLock or GlobalFree function. To obtain a pointer to the resource data, call the \Program%20Files\Microsoft%20Visual%20Studio\MSDN\2001JUL\1033\winui.chm::/hh/winui/resource_4co5.htm" target="_blank">LockResource function. |
|
[求助]关于完成端口的单IO数据的问题
PerIO Data在发送投递和接收投递的时候new出来比较合适 PerIO Data 是对应的一次发送或者接受操作,和每一个Sodick对应的数据是PerHandleData,代表一次会话 如果有多个线程操作的话,一定要加锁保护 数据在使用完了就可以释放了,建议自己实现一个Pool来管理内存。 在接收完成后,一般要再投第一个接收请求。 在发送完成后,可能没有将所有数据都发送出去,移动一下指针继续发送。 |
|
[求助]exe运行时,整个文件都加载到内存里吗?
开始只是对文件中的代码段、数据段等(不是所有区段)建立内存映射,并且只将工作集加载到内存里(建立物理内存映射),就开始运行了,没有被加载到内存的地址被访问时会自动加载(缺页处理)。 |
|
如何获取到checkbox那个正方形的小方块位置呢
说说思路吧: 使用WindowFromPointer、FindWindow等得到窗口句柄 使用GetWindowRect获得窗口位置 使用ClientToScreen、ScreemToClient等进行坐标系转换 希望对你有用! |
|
[求助]磁盘是怎么寻址的?
没有制造skynet的想法,好奇而已。 |
|
[求助]请教几个小问题
有时间是要好好研究一下,谢谢指教! |
|
|
|
我是新人.关于游戏技能代码有些问题
网络上的数据包就是内存中的数据包加上各层协议包头,如TCP协议从里向外依次是TCP首部-IP首部-以太网帧首部 |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值