It works!
Here the Tcl Server Code - Returned "Hello" hardcoded.
#!/usr/local/bin/tclsh7.5
set svcPort 9999
# Implement the service
# This example just writes the info back to the client...
proc doService {sock msg} {
# puts $sock "echosrv:$l"
puts $sock "Hello"
}
# Handles the input from the client and client shutdown
proc svcHandler {sock} {
set l [gets $sock] ;# get the client packet
if {[eof $sock]} { ;# client gone or finished
close $sock ;# release the servers client channel
} else {
doService $sock $l
}
}
# Accept-Connection handler for Server.
# called When client makes a connection to the server
# Its passed the channel we're to communicate with the client on,
# The address of the client and the port we're using
#
# Setup a handler for (incoming) communication on
# the client channel - send connection Reply and log connection
proc accept {sock addr port} {
# if {[badConnect $addr]} {
# close $sock
# return
# }
# Setup handler for future communication on client socket
fileevent $sock readable [list svcHandler $sock]
# Read client input in lines, disable blocking I/O
fconfigure $sock -buffering line -blocking 0
# Send Acceptance string to client
#puts $sock "$addr:$port, You are connected to the echo server."
#puts $sock "It is now [exec date]"
# log the connection
#puts "Accepted connection from $addr at [exec date]"
}
# Create a server socket on port $svcPort.
# Call proc accept when a client attempts a connection.
socket -server accept $svcPort
vwait events ;# handle events till variable events is set
Here the DB Code (from the Echo example)
#constant ECHO_PORT 9999
#constant SERVER_NAME "localhost"
IPAddress as dword
Connection as dword
ReturnStr as string
print "Press a key to start the client"
wait key
IPAddress = HOSTNAME TO IP( SERVER_NAME )
if IPAddress = 0 then Abort("Unable to determine the IP address")
Connection = NEW CONNECT SOCKET( IPAddress, ECHO_PORT)
if Connection = 0
Abort("Unable to get a connection to the server")
endif
if SEND SOCKET STRING( Connection, "Hello World" ) <= 0
Abort("Unable to transmit")
endif
SHUTDOWN SOCKET SEND Connection
ReturnStr = RECV SOCKET STRING$( Connection )
if SOCKET ERROR() > 0
Abort("Unable to receive")
endif
print "I got this back : "; ReturnStr
DELETE SOCKET Connection
print "Press a key to exit"
wait key
end
function Abort(Msg as string)
print "Error : "; Msg
print "Error : ("; SOCKET ERROR(); ") "; SOCKET ERROR$()
wait key
end
endfunction
Seems it was a good decision to work with DPPro now.