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/

Committer:
cassyarduino
Date:
Wed Dec 21 16:58:10 2016 +0100
Revision:
0:e3fb1267e3c3
initial release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cassyarduino 0:e3fb1267e3c3 1 #!/usr/bin/perl
cassyarduino 0:e3fb1267e3c3 2 #udpserver.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,$received_data);
cassyarduino 0:e3fb1267e3c3 10 my ($peeraddress,$peerport);
cassyarduino 0:e3fb1267e3c3 11
cassyarduino 0:e3fb1267e3c3 12 # we call IO::Socket::INET->new() to create the UDP Socket and bound
cassyarduino 0:e3fb1267e3c3 13 # to specific port number mentioned in LocalPort and there is no need to provide
cassyarduino 0:e3fb1267e3c3 14 # LocalAddr explicitly as in TCPServer.
cassyarduino 0:e3fb1267e3c3 15 $socket = new IO::Socket::INET (
cassyarduino 0:e3fb1267e3c3 16 LocalPort => '5000',
cassyarduino 0:e3fb1267e3c3 17 Proto => 'udp',
cassyarduino 0:e3fb1267e3c3 18 ) or die "ERROR in Socket Creation : $!\n";
cassyarduino 0:e3fb1267e3c3 19
cassyarduino 0:e3fb1267e3c3 20 while(1)
cassyarduino 0:e3fb1267e3c3 21 {
cassyarduino 0:e3fb1267e3c3 22 # read operation on the socket
cassyarduino 0:e3fb1267e3c3 23 $socket->recv($recieved_data,1024);
cassyarduino 0:e3fb1267e3c3 24
cassyarduino 0:e3fb1267e3c3 25 #get the peerhost and peerport at which the recent data received.
cassyarduino 0:e3fb1267e3c3 26 $peer_address = $socket->peerhost();
cassyarduino 0:e3fb1267e3c3 27 $peer_port = $socket->peerport();
cassyarduino 0:e3fb1267e3c3 28 print "($peer_address , $peer_port) said : $recieved_data\n";
cassyarduino 0:e3fb1267e3c3 29
cassyarduino 0:e3fb1267e3c3 30 #send the data to the client at which the read/write operations done recently.
cassyarduino 0:e3fb1267e3c3 31 $data = "data from server\n";
cassyarduino 0:e3fb1267e3c3 32
cassyarduino 0:e3fb1267e3c3 33 $socket->send($data);
cassyarduino 0:e3fb1267e3c3 34
cassyarduino 0:e3fb1267e3c3 35 print $socket "$data";
cassyarduino 0:e3fb1267e3c3 36
cassyarduino 0:e3fb1267e3c3 37 }
cassyarduino 0:e3fb1267e3c3 38
cassyarduino 0:e3fb1267e3c3 39 $socket->close();
cassyarduino 0:e3fb1267e3c3 40