Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Reading data from socket on Windows appends extra '0' value

Closed / Fixed218047ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:52:33
OriginalBugID: 1398 Bug
Version: 8.0.4
SubmitDate: '1999-03-02'
LastModified: '2000-04-24'
Severity: SER
Status: Closed
Submitter: pat
ChangedBy: hobbs
OS: Windows NT
OSVersion: 4.0, service pack 3
Machine: X86
FixedDate: '2000-10-25'
ClosedDate: '2000-04-24'


Name:
Fred Roeber

Extensions:
DP

CustomShell:
patch from Bug ID 893

ReproducibleScript:
The code we are using to receive data over a TCP socket follows.

# set up a socket to handle upload requests (will call tscan_socket)
if {[catch {socket -server tscan_socket $tscan_port} tscan_server_id]} {
    # command failed so signal receive disabled
    tscan_display "Error - couldn't connect socket: $tscan_server_id"
}

proc tscan_socket {chan_id ip_addr port} {
    global tscan_file_id

    if {[catch {open "dummy" "w"} tscan_file_id]} {
        # problem opening file
        tscan_display "Error - couldn't open file: $tscan_file_id"
        close $chan_id
        return
    }
    fconfigure $tscan_file_id -translation binary -blocking no

    # set up to receive the upload data
    fconfigure $chan_id -translation binary -blocking no
    fileevent $chan_id readable "tscan_socket_read $chan_id $tscan_file_id"
}

proc tscan_socket_read {chan_id file_id} {
    if {[catch {read $chan_id} data]} {
        tscan_display "problem reading TimeScan data from socket"
    } elseif {[eof $chan_id]} {
        tscan_display "Done"
    } elseif {[catch {puts -nonewline $file_id $data} file_err]} {
        tscan_display "Error writing TimeScan data to file: $file_err"
    } else {
        # everything worked so we are done. Do a display update so that program
        # isn't unresponsive
        update
        return
    }

    # we had some problem so shut down channel
    catch {close $chan_id}
    catch {close $file_id}
}




ObservedBehavior:
This code above works fine under Solaris. Under windows, we receive an
extra '0' byte (not '\0') from the socket connection that gets written to the
output file. If the system sending the data just opens a closes a TCP
connection, we get a 0 byte file on Solaris but a 1 byte file under
Windows/NT 4.0.






DesiredBehavior:
I expect Solaris and windows to produce the same resultswith the code above.





As a note of reference, I found the patch for bug ID 893 on your site. I
installed it as it was required to have it installed to get asynchronous
sockets to be properly opened under Windows.

--
I'm not able to reproduce this with 8.2.3 on NTsp4. 
-- 04/19/2000 hobbs
Response from user:

Hello, I had found out the source of this problem after submitting the
report. The issue was that the sending application was sending up an
OOB (out of band) message with a '0' in it before closing the socket.
The intent was the "wake up" the host so it could close the socket
quickly. Windows doesn't support OOB messages on sockets so added the
'0' to the output stream. I just chalked this up as one of those Unix
vs Windows TCP/IP stack differences. Thanks for the response.  Fred

   |      Fred J Roeber,  BBN Systems & Technologies      |
 
-- 04/24/2000 hobbs
welch Closed ticket [218047ffff]. [History diff]2000-10-26 08:13:44
dgp Ticket [218047ffff]: 1 change [History diff]2001-04-01 01:48:02
dgp Ticket [218047ffff]: 2 changes [History diff]2001-04-01 01:48:03
Log in (anonymous is fine) to add a comment.