home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 033 / atcp40de.zip / TCP.EL < prev    next >
Lisp/Scheme  |  1994-10-07  |  3KB  |  68 lines

  1. ;;; TCP/IP stream emulation for GNU Emacs
  2. ;; Copyright (C) 1988, 1989 Fujitsu Laboratories LTD.
  3. ;; Copyright (C) 1988, 1989 Masanobu UMEDA
  4. ;; $Header: tcp.el,v 1.4 89/06/19 13:38:59 umerin Locked $
  5.  
  6. ;; This file is part of GNU Emacs.
  7.  
  8. ;; GNU Emacs is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  10. ;; accepts responsibility to anyone for the consequences of using it
  11. ;; or for whether it serves any particular purpose or works at all,
  12. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  13. ;; License for full details.
  14.  
  15. ;; Everyone is granted permission to copy, modify and redistribute
  16. ;; GNU Emacs, but only under the conditions described in the
  17. ;; GNU Emacs General Public License.   A copy of this license is
  18. ;; supposed to have been given to you along with GNU Emacs so you
  19. ;; can know your rights and responsibilities.  It should be in a
  20. ;; file named COPYING.  Among other things, the copyright notice
  21. ;; and this notice must be preserved on all copies.
  22.  
  23. ;; Notes on TCP package:
  24. ;;
  25. ;; This package provides a TCP/IP stream emulation on GNU Emacs. If
  26. ;; the function `open-network-stream' is not defined in Emacs, but
  27. ;; your operating system has a capability of network stream
  28. ;; connection, this tcp package can be used for communicating with
  29. ;; NNTP server.
  30. ;;
  31. ;; The tcp package runs inferior process named `tcp' which actually
  32. ;; does the role of `open-network-stream'. Before loading the package,
  33. ;; compile `tcp.c' and install it as `tcp' in a direcotry in the emacs
  34. ;; search path. If you modify `tcp.c', please send diffs to the author
  35. ;; of GNUS.  I'll include some of them in the next releases.
  36.  
  37. (provide 'tcp)
  38.  
  39. (defvar tcp-program-name "tcp"
  40.   "A name of the program emulating open-network-stream function.")
  41.  
  42. (defun open-network-stream (name buffer host service)
  43.   "Open a TCP connection for a service to a host.
  44. Returns a subprocess-object to represent the connection.
  45. Input and output work as for subprocesses; `delete-process' closes it.
  46. Args are NAME BUFFER HOST SERVICE.
  47. NAME is name for process.  It is modified if necessary to make it unique.
  48. BUFFER is the buffer (or buffer-name) to associate with the process.
  49.  Process output goes at end of that buffer, unless you specify
  50.  an output stream or filter function to handle the output.
  51.  BUFFER may be also nil, meaning that this process is not associated
  52.  with any buffer
  53. Third arg is name of the host to connect to.
  54. Fourth arg SERVICE is name of the service desired, or an integer
  55.  specifying a port number to connect to."
  56.   (let ((proc
  57.      (start-process name buffer 
  58.             tcp-program-name
  59.             "-h" host 
  60.             "-s" (if (stringp service)
  61.                  service
  62.                    (int-to-string service))
  63.             )))
  64.     (process-kill-without-query proc)
  65.     ;; Return process
  66.     proc
  67.     ))
  68.