diff options
author | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
---|---|---|
committer | Sam T <pxqr.sta@gmail.com> | 2013-06-12 06:34:19 +0400 |
commit | 8b005c4eb0f58db974c342efe0821240f39a6331 (patch) | |
tree | 85a32db63949ed1082a61100b71fcb830e1044e5 /src/Network/BitTorrent/Exchange/Protocol.hs | |
parent | 7f27eec9bf34a513f7a28072468706e8975ef552 (diff) |
+ Rename to await and yield.
Diffstat (limited to 'src/Network/BitTorrent/Exchange/Protocol.hs')
-rw-r--r-- | src/Network/BitTorrent/Exchange/Protocol.hs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Network/BitTorrent/Exchange/Protocol.hs b/src/Network/BitTorrent/Exchange/Protocol.hs index 718e339d..6b97d8d1 100644 --- a/src/Network/BitTorrent/Exchange/Protocol.hs +++ b/src/Network/BitTorrent/Exchange/Protocol.hs | |||
@@ -164,14 +164,18 @@ defaultHandshake = Handshake defaultBTProtocol defaultReserved | |||
164 | -- | Handshaking with a peer specified by the second argument. | 164 | -- | Handshaking with a peer specified by the second argument. |
165 | handshake :: Socket -> Handshake -> IO Handshake | 165 | handshake :: Socket -> Handshake -> IO Handshake |
166 | handshake sock hs = do | 166 | handshake sock hs = do |
167 | putStrLn "send handshake" | ||
167 | sendAll sock (S.encode hs) | 168 | sendAll sock (S.encode hs) |
168 | 169 | ||
170 | putStrLn "recv handshake size" | ||
169 | header <- recv sock 1 | 171 | header <- recv sock 1 |
170 | when (B.length header == 0) $ | 172 | when (B.length header == 0) $ |
171 | throw $ userError "Unable to receive handshake." | 173 | throw $ userError "Unable to receive handshake." |
172 | 174 | ||
173 | let protocolLen = B.head header | 175 | let protocolLen = B.head header |
174 | let restLen = handshakeSize protocolLen - 1 | 176 | let restLen = handshakeSize protocolLen - 1 |
177 | |||
178 | putStrLn "recv handshake body" | ||
175 | body <- recv sock restLen | 179 | body <- recv sock restLen |
176 | let resp = B.cons protocolLen body | 180 | let resp = B.cons protocolLen body |
177 | 181 | ||