diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-04-20 19:04:47 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-04-20 19:04:47 +0000 |
commit | 4e3cf63c95fc3c01a1c759e237678e9d3b2b8494 (patch) | |
tree | 430debfcb216d8a291073f4d823883c0115f4516 | |
parent | 2a00a5ad50f2ac4ed19fa6a84c59f539076e8c2a (diff) | |
download | luasocket-4e3cf63c95fc3c01a1c759e237678e9d3b2b8494.tar.gz luasocket-4e3cf63c95fc3c01a1c759e237678e9d3b2b8494.tar.bz2 luasocket-4e3cf63c95fc3c01a1c759e237678e9d3b2b8494.zip |
Removed debuging prints.
-rw-r--r-- | samples/forward.lua | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/samples/forward.lua b/samples/forward.lua index c213a59..ff65b84 100644 --- a/samples/forward.lua +++ b/samples/forward.lua | |||
@@ -72,16 +72,12 @@ end | |||
72 | -- starts a connection in a non-blocking way | 72 | -- starts a connection in a non-blocking way |
73 | function connect(who, host, port) | 73 | function connect(who, host, port) |
74 | who:settimeout(0) | 74 | who:settimeout(0) |
75 | print("trying to connect peer", who, host, port) | ||
76 | local ret, err = who:connect(host, port) | 75 | local ret, err = who:connect(host, port) |
77 | if not ret and err == "timeout" then | 76 | if not ret and err == "timeout" then |
78 | print("got timeout, will wait", who) | ||
79 | wait(who, "output") | 77 | wait(who, "output") |
80 | ret, err = who:connect(host, port) | 78 | ret, err = who:connect(host, port) |
81 | print("connection results arrived", who, ret, err) | ||
82 | end | 79 | end |
83 | if not ret then | 80 | if not ret then |
84 | print("connection failed", who, err) | ||
85 | kick(who) | 81 | kick(who) |
86 | kick(context[who].peer) | 82 | kick(context[who].peer) |
87 | else | 83 | else |
@@ -104,7 +100,6 @@ function accept(server) | |||
104 | while true do | 100 | while true do |
105 | -- accept a new connection and start a new coroutine to deal with it | 101 | -- accept a new connection and start a new coroutine to deal with it |
106 | local client = server:accept() | 102 | local client = server:accept() |
107 | print("accepted ", client) | ||
108 | if client then | 103 | if client then |
109 | -- create contexts for client and peer. | 104 | -- create contexts for client and peer. |
110 | local peer, err = socket.tcp() | 105 | local peer, err = socket.tcp() |
@@ -139,7 +134,6 @@ end | |||
139 | 134 | ||
140 | -- forwards all data arriving to the appropriate peer | 135 | -- forwards all data arriving to the appropriate peer |
141 | function forward(who) | 136 | function forward(who) |
142 | print("starting to foward", who) | ||
143 | who:settimeout(0) | 137 | who:settimeout(0) |
144 | while true do | 138 | while true do |
145 | -- wait until we have something to read | 139 | -- wait until we have something to read |
@@ -173,24 +167,8 @@ end | |||
173 | -- what happened, and routing it to wait until something else happens | 167 | -- what happened, and routing it to wait until something else happens |
174 | function go() | 168 | function go() |
175 | while true do | 169 | while true do |
176 | print("will select for reading") | ||
177 | for i,v in ipairs(receiving) do | ||
178 | print(i, v) | ||
179 | end | ||
180 | print("will select for sending") | ||
181 | for i,v in ipairs(sending) do | ||
182 | print(i, v) | ||
183 | end | ||
184 | -- check which sockets are interesting and act on them | 170 | -- check which sockets are interesting and act on them |
185 | readable, writable = socket.select(receiving, sending, 3) | 171 | readable, writable = socket.select(receiving, sending) |
186 | print("was readable") | ||
187 | for i,v in ipairs(readable) do | ||
188 | print(i, v) | ||
189 | end | ||
190 | print("was writable") | ||
191 | for i,v in ipairs(writable) do | ||
192 | print(i, v) | ||
193 | end | ||
194 | -- for all readable connections, resume its thread | 172 | -- for all readable connections, resume its thread |
195 | for _, who in ipairs(readable) do | 173 | for _, who in ipairs(readable) do |
196 | receiving:remove(who) | 174 | receiving:remove(who) |