Created
February 15, 2012 06:06
-
-
Save underhilllabs/1833697 to your computer and use it in GitHub Desktop.
Connect to Chatserver from Emacs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; set the port of the Chat Server | |
(defvar port 1337) | |
;; set the host of the Chat Server | |
(defvar host "localhost") | |
(defun my-chat () | |
"Chat client for chat server assignment" | |
(interactive) | |
;; open-network-stream creates a socket to the Chat Server | |
;; setq associates the socket with the pointer "chat-client" | |
(setq chat-client (open-network-stream "chat-room" "chat-room" host port)) | |
(while (not (string= (setq answer (read-from-minibuffer "> ")) "quit")) | |
;; process-send-string writes the string answer to the socket assoc with chat-client | |
(process-send-string chat-client (format "%s" answer)) | |
(switch-to-buffer "chat-room"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment