通过网络读取和写入文件 [英] Reading and Writing files over a network

查看:111
本文介绍了通过网络读取和写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

真正的问题是:Windows是否存在已知问题''ReadFile(HANDLE hFile,
LPVOID lpBuffer,DWORD nNumberOfBytesToRead,LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped)函数给出一个返回值TRUE,其中hFile是有效的,lpBuffer是一个有效的指针,lpNumberOfBytesRead与nNumberOfBytesToRead相同,但是鉴于文件在另一台计算机上,lpBuffer的内容已损坏?

上下文:
远程计算机上的文件正在增长,并且随着该文件的增长,我想在本地计算机上保留该文件的副本.我可以使用CopyFileEx(),并且可以正常工作,但是由于文件正在增长并且可能变得很大,所以我宁愿找到文件之间的差异,然后将差异复制(读取然后写入)到本地文件中.

我做了一些研究,我知道打开网络计算机上的文件时,将使用SMB(服务器消息块)发出请求,并使用TCP发送回响应.我实际上已经使用Wireshark记录了交易,并且发现网络计算机正确接收了请求并且正在发送正确的数据,但是接收计算机却收到很多CRC错误.

本地计算机:
Windows 7 Pro 32位
远程机器:
Windows XP Pro 32位(使用Virtual PC 2007的虚拟机)
Windows 7 Ultimate 32位(实际计算机)

对不起,我没有提供实际的代码,我正在研究一个测试用例.但是我对了解基于此的知识中是否有一些东西更感兴趣.

该代码用C/C ++编写.

谢谢,

The real question is: is there a known problem with Windows'' ReadFile(HANDLE hFile,
LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped) function giving a return value of TRUE where hFile is valid, lpBuffer is a valid pointer, lpNumberOfBytesRead is the same as nNumberOfBytesToRead but the contents of lpBuffer is corrupt, given that the file is on another computer?

Context:
A file on a remote computer is growing and I want to keep a copy of that file on the local computer as it is growing. I could use CopyFileEx(), and that does work correctly, but because the file is growing and could get to be very large, I would rather find the differences between the files and copy (read and then write) the differences to the local file.

I''ve done a little bit of research and I know that when a file on a network computer is opened, the requests are made using SMB (Server Message Blocks) and the response is sent back using TCP. I have actually recorded the transactions using Wireshark and have found that the network computer is receiving the request correctly and is sending the correct data back, but the receiving computer is getting a lot of CRC errors.

Local Machine:
Windows 7 Pro 32-bit
Remote Machine:
Windows XP Pro 32-bit (virtual machine using Virtual PC 2007)
Windows 7 Ultimate 32-bit (actual machine)

Sorry for not putting up actual code, I am working on a test case. But I am more interested in knowing if there is something in the knowledge base on this.

The code is written in C/C++.

Thanks,

推荐答案

CRC错误与SMB或TCP或IP不相关,而与接收计算机的基础线路协议"(可能是以太网)相关,并且与损坏物理介质上的位.

就电缆/连接器的质量而言,您很可能对环境的电气噪声进行了错误的安装".
没有代码可以调整数据包变坏(除了需要重新传输之外,但这完全是TCP的工作,但性能降低)
CRC errors are not related to SMB or TCP or IP, but to the underlying "line protocol" (probably Ethernet) of the receiving computer, and relate to corruption of bits along the physical media.

You''ve most likely done a "bad installation" in term of cable/connectors quality respect to the environmental electric noise.
There is no code that can adjust a packet gone bad (apart requiring a retransmission, but it is exactly what the TCP does, but loosing in performance)


这篇关于通过网络读取和写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆