套接字编程中的音频文件. [英] Audio files in socket programming.

查看:73
本文介绍了套接字编程中的音频文件.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好..
我正在尝试使用Java在套接字编程中编写代码,该代码会将音频文件从1个目标传输到另一个目标.
我可以使用AudioInputStream和AudioSystem方法成功读取音频文件.
但是,我无法将同一文件写回目的地.客户端无法正确接收音频文件.
你能帮我吗?
我能够成功传输一个简单的文本文件..但它似乎不适用于音频文件..

谢谢n ..

Hello..
I am trying to write a code in socket programming using java that would transfer audio files from 1 destination to another.
I am able to read the audio file successfully using AudioInputStream and AudioSystem methods.
However, i am unable to write back the same file to the destination. The client side does not receive the audio file properly.
Please can u help me?
I was able to successfully transfer a simple text file..but it just doesn''t seem to work for audio files..

Thanks n regards..

推荐答案

如果可以编写简单的文本文件,可能出现碎片问题.

您可以尝试通过套接字进行序列化,也可以说它只是一个文件(不必关心其类型),然后将其读取到字节容器中,并在每次读取时通过套接字发送.这里的建议可能有用,不要使用太大的容器,可以使用大小为256的字节数组.
Probably fragmentation is the problem if you can write simple text file.

You can try serialization through socket or you could say it is just a file(dont care its type) and read it into a byte container and send it through socket each time you read. Here a suggestion could be useful, dont use too big container, you can use a byte array sized 256.


请详细说明一下?
您所说的代码片段到底是什么意思?
Could you please elaborate??
What exactly do u mean by fragmentation of code?


我已经回答了这个问题 ^ ];请不要在多个论坛中发帖,这只会使问题感到困惑.

问题是:以字节流的形式读取文件并将其发送给客户端.客户端应另存为字节流.该文件的客户端副本应为原始副本.如果不是这种情况,那么我怀疑您没有遵循上述模型.
I already answered this question here[^]; please do not post in multiple forums, it just confuses the issue.

The issue being: read your file as a byte stream and send it to the client. The client should save as a byte stream. The client copy of the file should be an exact copy of the original. If this is not the case then I suspect you are not following the above model.


这篇关于套接字编程中的音频文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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