Created
September 15, 2012 22:50
-
-
Save grafov/3730213 to your computer and use it in GitHub Desktop.
Send current buffer to server:port
This file contains 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
(defun tcp-send (server port &optional timeout) | |
"Отправить текст текущего буфера на server:port" | |
(if (not timeout) (setq timeout 60)) | |
(let* ((res "*TCP/Result*") | |
(cur-buf (buffer-name)) | |
(proc (open-network-stream "TcpRequest" | |
(progn (switch-to-buffer (get-buffer-create res)) | |
(erase-buffer) | |
(switch-to-buffer cur-buf) res) | |
server port))) | |
(process-send-string proc (buffer-string)) | |
(while (equal (process-status proc) 'open) | |
(when (not (accept-process-output proc timeout)) | |
(delete-process proc) | |
(error "Network timeout."))) | |
(switch-to-buffer res) | |
(beginning-of-buffer) | |
(split-window) | |
(switch-to-buffer cur-buf))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment