开发者

I/O streams, socket programming, interoperability

I am currently making a client-server file transfer program in java and my question is,

is there a best or an appropriate I/O streams to transfer files via sockets of different programs?

i am confused about what to used....

so far, i'm just using the bufferedoutputstream/bufferedinputstream pair and even though it works, it seems that there is something m开发者_如何学Cissing with all the concepts in mind...

what i really want to know is what stream will i use to transfer any files via socket if i am going to transfer them by byte array

and

if other program not written in java (let say c++) must be able to receive and save the sent file... (does serialization involve this?)

thanks. :)


The combination of stream/buffer classes will make no difference. You need to choose a format that is easy to read/write in the same way on all platforms. For example, writing binary data representing numbers is harder (though not impossible) for different processor architectures to read.

Why not use HTTP as your protocol? It mostly sends lines of plain text, using blank lines as delimiters. Among the advantages of this is that you can use a wealth of existing tools to debug/analyse your system, e.g. curl, Fiddler, any web browser, etc. Clients (and server frameworks) already exist for thousands of platforms.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜