Sockets help
- From: Robert Hicks <sigzero@xxxxxxxxx>
- Date: Tue, 14 Aug 2007 23:04:40 -0000
Someone emailed this to me but it is above my skills:
a very simple socket function, client and server. Works fine.
Now, through a proxy in between.
client socket connect to the proxy and ask proxy to forward the
message to server. In this case, proxy also make a socket connection
to server. Server puts data into the socket from proxy.
The situation is that, the socket has to close on Server in order for
the data to flow to proxy then back to client.
in client:
::http::config -proxyhost xxx.xxx.xx.xxx -proxyport 1234
::http::register http 1234 ::socket
http::geturl "http://yyy.yyy.yy.yy:5678 -handler httpdisplay
proc httpdisplay { socket token } {
puts [gets $socket]
}
proxy is locate at xxx.xxx.xx.xxx of port 1234
server side:
socket -server Accept 5678
proc Accpet { sock addr port } {
fconfigure $sock -buffering none -blocking 0
fileevent $sock readable [list display $sock $addr $port]
}
proc display { sock addr port } {
set line [gets $sock]
puts $sock "Data received: $line"
flush $sock
}
Well, the problem is that if I don't use proxy,
httpdisplay output data right away. But if I used proxy, then no data
will show until I put a close in proc display in Server side after I
wrote the data to $sock.
Can you help?
Thanks,
.
- Follow-Ups:
- Re: Sockets help
- From: Bruce Hartweg
- Re: Sockets help
- Prev by Date: Re: What's the most important thing lacking in your Tcl toolbox?
- Next by Date: Re: Sockets help
- Previous by thread: http help please
- Next by thread: Re: Sockets help
- Index(es):
Relevant Pages
|