I am trying to adapt this python code that I found to connect to the Dropbox daemon:
def connect(self, cmd_socket="~/.dropbox/command_socket", iface_socket="~/.dropbox/iface_socket"): "Connects to the Dropbox command_socket, returns True if it was successfull." self.iface_sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) self.sck = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) try: self.sck.connect(os.path.expanduser(cmd_socket))
Here is what I still have:
public bool Connect (int port) { return Connect ("~/.dropbox/command_socket", "~/.dropbox/iface_socket", port); } public bool Connect (string cmdSocket, string ifaceSocket, int port) { IfaceSocket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); CmdSocket = new Socket (AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); try {
This compiles fine, but when I try to run it, I get a System.Net.Sockets.SocketException: No such host is known . I assume this is because cmdSocket and ifaceSocket are paths, not IP addresses. Python seems to handle this automatically, how do I do this in C #? This is my first foray into socket programming, so please indicate any obvious errors.
source share