xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmad Morad <mo...@db.informatik.uni-kassel.de>
Subject notice about WrappedInputstream() reading XML on Sockets
Date Thu, 21 Dec 2000 16:19:19 GMT
Thanks Andy, 

the WrappedInputStream works well. to simulate WrappedOutputstream in Tcl I 

# to write a message with optional header (text)
proc tcldbMessager_writeMessage {message {header ""}} {
    global CLIENT_SOCKET 
    # S (big endian !) the network standard! 
    if {$header != ""} {
	set messageLength [string length $header] 
	puts -nonewline $CLIENT_SOCKET "[binary format S ${messageLength}]$header" 
    set messageLength [string length $message] 
    puts -nonewline $CLIENT_SOCKET "[binary format S\                         
    puts -nonewline $CLIENT_SOCKET  "[binary format S 0]" 
    flush $CLIENT_SOCKET

# to write a file
proc tcldbMessager_writeFile {from} {
    global CLIENT_SOCKET
    set package_size 1024
    set total 0
    while {![eof $from]} {
	set message [read $from $package_size]
	set messageLength [string length $message]
	puts -nonewline $CLIENT_SOCKET \
		"[binary format S ${messageLength}]${message}" 
	incr total $messageLength
    puts -nonewline $CLIENT_SOCKET "[binary format S 0]"
    flush $CLIENT_SOCKET
    return $total

I think: its a good solution, at least for my application. And it also works 
well with xml produced with other languages (Tcl)


Dipl. Math. Morad Ahmad ///\\ morad@db.informatik.uni-kassel.de 
Universitaet Gh. Kassel['`|'`]www.db.informatik.uni-kassel.de/~morad
Heinrich-Plett-Str. 40 { ^ }Tel.: ++49(561)804-4101 
D-34109 Kassel, Germany \\// Fax: ++49(561)804-4199

View raw message