UIPEthernet library for Arduino IDE, Eclipse with arduino plugin and MBED/SMeshStudio (AVR,STM32F,ESP8266,Intel ARC32,Nordic nRF51,Teensy boards,Realtek Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet W5100 Ethernet library API. Compiled and tested on Nucleo-F302R8. Master repository is: https://github.com/UIPEthernet/UIPEthernet/
tests/perl/udpclient.pl@0:e3fb1267e3c3, 2016-12-21 (annotated)
- Committer:
- cassyarduino
- Date:
- Wed Dec 21 16:58:10 2016 +0100
- Revision:
- 0:e3fb1267e3c3
initial release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cassyarduino | 0:e3fb1267e3c3 | 1 | #!/usr/bin/perl |
cassyarduino | 0:e3fb1267e3c3 | 2 | #udpclient.pl |
cassyarduino | 0:e3fb1267e3c3 | 3 | |
cassyarduino | 0:e3fb1267e3c3 | 4 | use IO::Socket::INET; |
cassyarduino | 0:e3fb1267e3c3 | 5 | |
cassyarduino | 0:e3fb1267e3c3 | 6 | # flush after every write |
cassyarduino | 0:e3fb1267e3c3 | 7 | $| = 1; |
cassyarduino | 0:e3fb1267e3c3 | 8 | |
cassyarduino | 0:e3fb1267e3c3 | 9 | my ($socket,$data); |
cassyarduino | 0:e3fb1267e3c3 | 10 | |
cassyarduino | 0:e3fb1267e3c3 | 11 | # We call IO::Socket::INET->new() to create the UDP Socket |
cassyarduino | 0:e3fb1267e3c3 | 12 | # and bind with the PeerAddr. |
cassyarduino | 0:e3fb1267e3c3 | 13 | $socket = new IO::Socket::INET ( |
cassyarduino | 0:e3fb1267e3c3 | 14 | PeerAddr => '192.168.0.6:5000', |
cassyarduino | 0:e3fb1267e3c3 | 15 | Proto => 'udp' |
cassyarduino | 0:e3fb1267e3c3 | 16 | ) or die "ERROR in Socket Creation : $!\n"; |
cassyarduino | 0:e3fb1267e3c3 | 17 | #send operation |
cassyarduino | 0:e3fb1267e3c3 | 18 | $data = "data from client"; |
cassyarduino | 0:e3fb1267e3c3 | 19 | $socket->send($data); |
cassyarduino | 0:e3fb1267e3c3 | 20 | |
cassyarduino | 0:e3fb1267e3c3 | 21 | #read operation |
cassyarduino | 0:e3fb1267e3c3 | 22 | $data = <$socket>; |
cassyarduino | 0:e3fb1267e3c3 | 23 | print "Data received from socket : $data\n "; |
cassyarduino | 0:e3fb1267e3c3 | 24 | |
cassyarduino | 0:e3fb1267e3c3 | 25 | sleep(10); |
cassyarduino | 0:e3fb1267e3c3 | 26 | $socket->close(); |