Thread: SSHDOS linux modification GET problem

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    2

    SSHDOS linux modification GET problem

    Hi!, Iīm working with sshdos to make an sftp linux client.

    The client connects, list and put files without problem.
    But with "get" happends something strange.
    With files that have small size (less than 1 K or less), no problem; but when I try to get any file with more size, the applicattion says; Socket read error on trasprt.c At this point:

    if (n = read(GlobalConfig.s,inbuf+16,PktLength-16) != PktLength - 16)

    But only fails if the filesize is greater than 1kb moreless.

    Anybody knows what happens?? Why this socket reading fails only for this files?

    Sorry my poor english, thanks

    PD: Also fails listing files if before puts a file (greater than 1kb).

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well the socket code is broken, in that it assumes that the buffer will be filled every time.

    This is simply not the case for network TCP traffic, as messages can be fragmented on transmission and delivery.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    2
    I donīt understand your reply.
    This program runs with paquets, this line read the rest of packet (before I have read the header with if ((n = read(GlobalConfig.s,PktInLength,16)) != 16)

    And all the process of authentification, listing,put,get.... runs with packets and runs ok.
    Only fails with long packets with get. (with put donīt worry sizes).
    The code is so large to post here, but if was necesary I post it.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    http://www.cs.ucla.edu/classes/fall0...s/distcomp.pdf
    In particular, Slide 18

    If you send 10 bytes followed by another 10 bytes, then it is pure LUCK if you receive 10 bytes and 10 bytes.

    What is more usual, especially when you start to bump up the data volumes is that messages become fragmented.

    So sending 10 + 10 might be received as 7 + 9 + 4. It's still a total of 20 in and 20 out, but it's YOUR job to reassemble the data into meaningful packets of data.

    By the same token, asking to send 10 bytes might only result in part of the data being sent, in which case you need to retry with the remainder.

    TCP is a stream protocol, which means you're guaranteed to get the bytes out the same order that you put them in - nothing more. Fragmentation at both ends is something you have to take into account.

    UDP is different, either you get the whole message in its entirety, or you get nothing. That is, it is an unreliable connection. Also, UDP packets can arrive out of order.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ in linux problem (long program)
    By Goldrak in forum C++ Programming
    Replies: 3
    Last Post: 04-24-2006, 05:45 PM
  2. OpenGL Linux Line Drawing Problem
    By swanley007 in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2006, 09:31 AM
  3. Replies: 1
    Last Post: 10-18-2005, 10:20 AM
  4. Problem with C++ in linux
    By MelaOS in forum C++ Programming
    Replies: 2
    Last Post: 12-28-2003, 06:29 AM
  5. Linux modem problem
    By VooDoo in forum Linux Programming
    Replies: 5
    Last Post: 08-19-2002, 05:34 AM