TCL8.4 Sockets not passing data until closed
Posted by Micah_Death (Micah_Death), 2 March 2005OS = Windows 95
Now something odd is happening...
I create 2 VB6 Apps to test this...
VBApp#1 - Server
Listen on Port 1001
Allow incoming connections
Display data sent to it
VBApp#2 - Client
Connect to 127.0.0.1:1000
Send a string
Accept Connection on port 1000
Create ConnectionAccept Callback
Create socket to 127.0.0.1:1001
Create Data Callback, pass source, destination
Get Data from source
send data to destination
Now the problem...
The client connects fine AND does not error when I pass data to the TCL Script... It does not how ever pass it to the server UNTIL I close the clients connection... When I close the clients connection it pushes everything to the server... How do I make it send to server instantly so that I can make the server send data back to the client?
I've recoded this twice from scratch with same problem... The TCL Script won't send the data to the second connection until I close the first connection....
Posted by admin (Graham Ellis), 3 March 2005Not an obvious one (you know this, I'm sure ) but three things strike me:
a) Have you tried using fconfigure and switching buffering mode to none? (Yes, I see that flush didn't help, but pre-empting it before things get stopped in the buffer may help)
b) Are you certain that the problem is in your Tcl and not in the receiving application? Is it possible that the receiving application buffers information and only acts on it when it gets a trigger such as a close, or a \r (rather than a \n) or something like that?
c) Earlier Windows operating systems had a very clunky switch from one concurrent application to another - they were described to me as "not really multitasking" by folks but I'm more of a Unix / Linux person and didn't do a deep study myself. Bearing in mind this reputation, I wonder if your computer is stuck in your Tcl and won't swap to the next application until the Tcl is done in some way / kickc out. It's possible that action (a) may cure this if it's the problem. For further invertigation, can you tranfer you code for test purposes to another OS and see if it works there?
Posted by Micah_Death (Micah_Death), 3 March 2005for a)
I did try fconfigure -buffering none
Didn't seem to help... I'll do it again and may post a little log file to show what it does... (I had this code in place before I scaled down the code looking for the bug... will try again with it to be sure.)
\r and \n should have no effect
(I built the Proxy in VB6 First and then converted to TCL... VB6 version works perfect with the VB test clients and with a real world client (Don't wish to release that information at this time but will if you request it.)
I need to test on Win98 or WinXP; so far I have only used Win95...
I'll post back again after I get to test a couple of things.
btw... When I'm done, I'll be redoing it to send Binary Data instead of strings, but strings are WAY easier to test with.[b][/b]
Posted by Micah_Death (Micah_Death), 4 March 2005as far as A: Goes...
fconfigure $sock -buffering none
Added (as well as the above):
fconfigure $Proxy(client) -buffering none
As far as B: goes... VB6 is based only on events so if I do a "Winsock1.Senddata Data" it will send the data, process other commands directly after it and then it's done... No buffering takes place. (Adding buffering to VB is sometimes tidious) -- This is why I don't think it is VB related... [And I made a VB6 Proxy first and everything worked with the app I was using it with]
As far as C: Goes...
Installed TCL on a Windows 2003 Server Box and copied the TCL Script. Change all references from local host to Windows 95 Machine IP (VB6 Apps still on the Win95 Box, but TCL Script is now on 2003 Server)...
Same Problem... TCL Doesn't send anything to the server until after I close the client...
Next Test: Run all Apps on 2003 Server
This leads me to believe its how I'm running the code...
Ways to run code I have tried with same results:
Hmm... I'm at a loss.
I noticed something when I first installed TCL on Windows... When I ran a script that did puts <args> I noticed that TCL didn't print anything to the screen until the program exited (Thats Why I use a logfile in above code)
It seemed TCL processed at least some of the data, but output was stopped until I close the TCL App.
Posted by Micah_Death (Micah_Death), 4 March 2005Woot! I think I got it!!!
added to fconfigure:
And it would push data instantly!!! =)
Thank you for your help =) -- you helped me troubleshoot and sent me in the right direction! =)
Posted by admin (Graham Ellis), 6 March 2005on 03/04/05 at 20:00:22, Micah_Death wrote:
Micah, so glad that we got it sorted, and many thanks for following up.
As a trainer, I'm always delighted when suggestions and ideas that I make here lead to people finding a solution even when I can't put my finger on it straight away - on of a good trainer's objectives is to help folks learn enough background so that the can go on and solve other issues more easily
Posted by Micah_Death (Micah_Death), 7 March 2005=)
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho