如何通过C编程发送和接收图像 [英] How to send and receive images through C programming

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

问题描述





我想知道如何用C编程发送和接收消息

a。是否真的可以用C />
b发送和接收图像。我尝试了几个代码,但我甚至无法接收图像的字节数组..

Hi,

I would like to know how to send and receive messages in C programming
a. is it really possible to send and receive images in C
b. i tried few codes but i am not even able to receive byte array of the images..

推荐答案

通过C中的套接字发送图像应该没问题。

这是一个如何在Windows上使用套接字的教程: Winsock教程 - 套接字编程在C上的Windows [ ^ ]



图像或任何存储为文件的数据都可以看作是二进制数据流。

因此,你可以轻松地将任何文件的内容读入缓冲区并通过TCP / IP发送和接收缓冲区。



在发送方和接收方使用fopen和fread fopen和fwrite。

应该有很多关于如何读写二进制文件的例子。



[更新]

正如OP所说的那样使用Linux,我也在Linux上为套接字添加一些链接。

套接字教程 [ ^ ]

< a href =http://www.binarytides.com/socket-programming-c-linux-tutorial/> Linux上的C语言编程 - 教程 [ ^ ]

C中的网络和套接字编程教程 [ ^ ]
It should be no problem to send an image via sockets in C.
Here is a tutorial for how to use sockets on Windows: Winsock tutorial – Socket programming in C on windows[^]

An image, or any data stored as a file, can be seen as a stream of binary data.
Hence, you can easily read the contents of any file into a buffer and send and receive the buffer over TCP/IP.

Use fopen and fread on the sending side and on the receiving side fopen and fwrite.
There should be plenty of examples out there for how to read and write binary files.

[UPDATE]
As the OP has stated that Linux is used, I add some links for sockets on Linux as well.
Sockets Tutorial[^]
Socket programming in C on Linux – tutorial[^]
Networking and Socket programming tutorial in C[^]


这篇关于如何通过C编程发送和接收图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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