Permalink
Browse files

Rename Ports to Channels

  • Loading branch information...
1 parent a5a2330 commit 1588dfdf68f3c79bdb60e4f82303152bec75c07a Tony Arcieri committed Oct 5, 2010
Showing with 13 additions and 10 deletions.
  1. +8 −5 lib/tcpsocket.re
  2. +4 −4 src/builtins/{port.re → channel.re}
  3. +1 −1 src/core/reia_dispatch.erl
View
@@ -32,19 +32,22 @@ class TCPSocket
case erl.gen_tcp.connect(host.to_list(), port, option_list)
when (:ok, socket)
- @sock = socket
+ @channel = socket
when (:error, :nxdomain)
throw(ResolveError, "cannot resolve '#{host}'")
when error
throw(error.inspect())
end
end
- def initialize(@sock); end
+ def initialize(@channel); end
+
+ # Retrieve the Channel for this socket
+ def channel; @channel; end
# Read the specified amount of data from the socket. A read of length zero
# will read all data available.
def read(length)
- case erl.gen_tcp.recv(@sock, length)
+ case erl.gen_tcp.recv(@channel, length)
when (:ok, packet)
packet
when (:error, :closed)
@@ -58,7 +61,7 @@ class TCPSocket
# Write the given data to the socket
def write(data)
- case erl.gen_tcp.send(@sock, data.to_binary())
+ case erl.gen_tcp.send(@channel, data.to_binary())
when :ok
true
when (:error, reason)
@@ -68,7 +71,7 @@ class TCPSocket
# Close the socket
def close
- case erl.gen_tcp.close(@sock)
+ case erl.gen_tcp.close(@channel)
when :ok
true
when (:error, reason)
@@ -1,15 +1,15 @@
#
-# pid.re: Methods of the Port builtin
+# channel.re: Methods of the Channel builtin
# Copyright (C)2010 Tony Arcieri
#
# Redistribution is permitted under the MIT license. See LICENSE for details.
#
-class Port
- def class; Port; end
+class Channel
+ def class; Channel; end
def to_string
- "#<Port:#{erl.port_to_list(self).to_string().sub('#Port<', '')}"
+ "#<Channel:#{erl.port_to_list(self).to_string().sub('#Port<', '')}"
end
def to_s; to_string(); end
@@ -45,6 +45,6 @@ call(Receiver, Method, Arguments, Block) when is_function(Receiver) ->
call(Receiver, Method, Arguments, Block) when is_pid(Receiver) ->
'Pid':call({Receiver, Method, Arguments}, Block);
call(Receiver, Method, Arguments, Block) when is_port(Receiver) ->
- 'Port':call({Receiver, Method, Arguments}, Block);
+ 'Channel':call({Receiver, Method, Arguments}, Block);
call(Receiver, _, _, _) ->
throw({error, unknown_receiver, Receiver}).

0 comments on commit 1588dfd

Please sign in to comment.