Skip to content

Instantly share code, notes, and snippets.

@grafov grafov/gist:3730213
Created Sep 15, 2012

Embed
What would you like to do?
Send current buffer to server:port
(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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.