help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UDP Socket


From: tomas
Subject: Re: UDP Socket
Date: Wed, 27 Jan 2016 13:22:56 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, Jan 27, 2016 at 12:12:43PM +0000, Tobias Reithmaier wrote:
> Hello,
> I have a question about emacs-lisp programming.There is a lack of 
> documentation for socket programming.
> I want to create an echo-Application.For Example:
> 
> (make-network-process :name "udp-socket1" :remote '[127 0 0 1 1500]
     :type 'datagram :filter 'print-it)(process-send-string "udp-socket1" 
"hello").
> ...now hopefully this sends an udp-datagram...How can i receive one?
> I guess, because where is no receive-function, this network-process receives
> datagrams automatically.But how can i send datagrams to over an udp-connection
> to this process.Not (process-send), but over udp with another elisp-program?

Here's something to get you started. Season to taste :-)

  (setq netty (make-network-process
               :name "netty"
               :type 'datagram
               :server t
               :family 'ipv4
               :service 1331
               :filter (lambda (proc string)
                         (message "proc <%S> said '%s'" proc string))))

If you want to talk to it, go to some terminal and say:

  echo "ding ding" | nc -u localhost 1331

All of that and more is in the Emacs Lisp reference, under 36 "Processes",
especially 36.14 "Network" to 36.17 "Low Level Network". Also of interest
(for the filter function) is 36.9 "Output from Processes".

Enjoy
- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlaotqAACgkQBcgs9XrR2kZuHQCaA+PxeY9lZOsS2J8Ai9WZeIuS
8U0AmwbI2N3jX+2sQgcAu9WLRr7HYqHv
=D7P7
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]