如何在C编程中发送文件和文件名? [英] How to send a file along with filename in C programming?

查看:117
本文介绍了如何在C编程中发送文件和文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我在tcp / ip中从客户端向服务器发送文件,在接收端,我很难编码文件名。而不是这个我希望收到与客户端相同的文件名。如何在c编程中实现这一目标?我可以提供一些示例代码供进一步参考。

Hi,

I am sending a file from client to server in tcp/ip, in the receiving end, i am hard coding the file-name. Instead of this i would like to receive the same file name as it is in client. How can this be achieved in c programming? Can i have some sample code for further reference.

推荐答案

如果你不能像PIEBALDconsult建议的那样使用FTP或HTTP(甚至是Kermit)你可能需要派生你的自己的'迷你协议' - 即,



1)Header =发送一个固定长度的文件名和文件中的字节数,也可能是一个校验和

2)数据=以字节形式发送文件

3)响应=收到并确认后收到响应(#bytes,checksum)



(但这一切都在重新发明轮子,当然)



'g'
If you cant use FTP or HTTP as PIEBALDconsult suggests (or even Kermit) you'd likely have to derive your own 'mini protocol' - ie,

1) Header = send a fixed length filename and the number of bytes in the file, maybe a checksum as well
2) Data = send the file as bytes
3) Response = receive a response back when its been received and acknowledged (# bytes, checksum)

(but all this is re-inventing the wheel, surely)

'g'


这篇关于如何在C编程中发送文件和文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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