jdk 1.3.1 tcp sockets

  • פותח הנושא J2EE
  • פורסם בתאריך

J2EE

New member
jdk 1.3.1 tcp sockets

שלום יש לי מספר שאלות שמטרידות אותי בנוגע לסוקטים מסוג TCP: 1. האם יש יתרון בשליחת אוביקט גדול בחלקים על פני שליחת אוביקט אחד גדול 2. כאשר אני מקבל קובץ אחד גדול האם יש דרך למדוד את ההתקדמות של קבלת הקובץ (נניח על מנת לתרגמה לprogress bar) 3. כאשר אני מקבל קובץ אחד גדול, האם יש דרך להפסיק את קבלת הקובץ, נניח בעקבות לחיצה על cancel שעושה הלקוח. תודה וחג שמח נ.ב. ואגב, האם ב jdk 1.4 זה כן אפשרי ?
 

dedtheded

New member
Progress bar

כדי להראות התקדמות , תשלח את גודל הקובץ מראש. כך תוכל לדעת כמה bytes התקבלו , ואיזה אחוז הם מגודל הקובץ. בר.
 

Edo Reshef

New member
TCP

About you questions: 1. Any block sent is usually break down to smaller peaces by one layer or another (communication layers). Even if you send one big block, the receiving side will probably get it spitted and will have to merge it into file again. Anyway it is common to send data with blocks of few Kilobytes at a time (depending on transfer speeds). 2. Progress bars are easy to implement. As someone said send some header before the file with the file info (name, Date, size etc.) and use the size field to estimate the received percentage. 3. TCP is Full-Duplex, means: bi-direction communication the receiving side can send Abort message while data is received (or just close the port). One last note, TCP/IP is not simple as it look, care should be taken for many things for bandwidth-loading to Threading and such... I would recommend do some serious reading before getting into this. Hope it help, Enjoy.​
 
למעלה