nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   Software Development (http://www.nvnews.net/vbulletin/forumdisplay.php?f=53)
-   -   How to split a file into packets. (http://www.nvnews.net/vbulletin/showthread.php?t=98109)

Tuork 09-09-07 04:44 PM

How to split a file into packets.
 
Hello everyone.
I have a networking assignment in which I have to transfer a file in groups of 8 256byte-packages, using JAVA.

Anyone know how I can break the file into the packages so I can send them through a socket connection?

Moreso, anyone have any ideas on how to implement a buffer on the serverside?

Any help is greatly appreciated.

bugmeplz 09-09-07 06:44 PM

Re: How to split a file into packets.
 
hi, you can just use FileInputStream to read in the raw bytes from the file you're trying to send to the server. You can use the FileInputStream to read in groups of 256 bytes, and then send them over to the socket on the server end. I am not sure what you mean regarding "how to implement a buffer on the serverside"; it can just be a byte[] that you fill up with the raw bytes sent over from the client. let me know if you have any more questions

BTW: it is rather confusing to use the term "package" since this has a definite meaning in java's jargon

Tuork 09-12-07 07:00 AM

Re: How to split a file into packets.
 
Quote:

Originally Posted by bugmeplz
hi, you can just use FileInputStream to read in the raw bytes from the file you're trying to send to the server. You can use the FileInputStream to read in groups of 256 bytes, and then send them over to the socket on the server end. I am not sure what you mean regarding "how to implement a buffer on the serverside"; it can just be a byte[] that you fill up with the raw bytes sent over from the client. let me know if you have any more questions

BTW: it is rather confusing to use the term "package" since this has a definite meaning in java's jargon

Thanks for the reply.

I did in fact use the InputStream to read raw bytes... same goes for what you mentioned about the buffer.

As for the packet deal, it was just the wording on my assignment that threw me off. What they meant was that I was supposed to send a certain amount of bytes per transmission.

Thanks a bunch!


All times are GMT -5. The time now is 05:45 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.