| |||||||||||
Socket prog. problem Posted by arunsri (arunsri), 7 April 2006 Hi grp,I'm using TCL for socket communication. I have the client prog. running on a Windows host (TCL 8.4) and a server on linux machine (tcl 8.4 again) My client connects to the server as follows: ------------------------------------------------------------------- #Initiate a client socket and connect to the server set sock [socket $target $send_port] puts "host/client: opened socket in host $target server(port) $send_port" #set socket parameters fconfigure $sock -buffering line -translation binary fileevent $sock readable [list talk_2_server $sock] #Wait and process events on the socket vwait forever ----------------------------------------------------------------- But the client (running on windows) dosent process any events when the vwait statement is issued. Also I hav checked to make sure that I am doing the proper clean-up in my code when I am done connecting to the server . i.e. close $sock set forever 1 Can you please give pointers as to what might be a problem ? Is it got anything to do with "vwait" on "Windows"? Please help. Posted by admin (Graham Ellis), 7 April 2006 Have you tested the server and client separately to establish which / where the problem lies? Use utilities such as telnet and a daemon such as httpd to try them out one by one with easy protocolsPosted by arunsri (arunsri), 7 April 2006 Right now I am testing if the client can talk to the server after establishing the connection i.e., just send and receive a few lines. Yes. Telnet does this. But my client prog. jus seem to stall from the vwait statement. Posted by arunsri (arunsri), 7 April 2006 I also verified with the simple "Echo" server program example (eg. 17_3 and 17_4) from the "Practical TCL/TK programming" book by Brent B. Welch (4th edition).No events are processes when I use "vwait event". I tried the client from another linux system too. It complains : can't wait for variable "event": would wait forever while executing "vwait event Now coming to my (project)problem: I want to be able to transfer a set of data from a windows PC to a linux box using TCL sockets. So I have a client.tcl running on windows and server.tcl on the linux. Upon getting the data the server has to execute a program and return back the output to the host windows pc? So naturally I have to use vwait in the client to wait for these events to be processed and the exit. So is there any other work around for this, as "vwait dosent work?" Posted by admin (Graham Ellis), 8 April 2006 Can't you simply loop on returned data and exit when you identify the end-of-file or a known sequence that indicates that the remote program has completed?The program that follows is a complete browser, an I've tested it on Windows ... Code:
In effect, you're using gets to wait for the server! This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |