Shop OBEX P1 Docs P2 Docs Learn Events
Spinneret UDP Client test — Parallax Forums

Spinneret UDP Client test

Beau SchwabeBeau Schwabe Posts: 6,557
edited 2011-09-07 13:30 in Accessories
Attached is a UDP Spinneret Client test program, where I'm running a UDP server on this end. I need some 'hits' to do some load testing, so if anyone cares to ping me with the attached Spinneret Client test program, that would be great.

Also there is a version of a Perl Test Script below that will also communicate with the Server if you don't have a Spinneret available.

Thanks.

Perl Test Script
#!/usr/bin/perl -w

require 5.003;

use IO::Socket;
$remote  = '24.253.241.231';

$port    = 5000; 
$iaddr   = inet_aton($remote)              or die "no host: $remote";

$paddr   = sockaddr_in($port, $iaddr);

$proto   = getprotobyname('udp');

socket(Socket_Handle, AF_INET, SOCK_DGRAM, $proto) or die "socket: $!";

$dgram   = "Sent from Perl Test Script" ;

send(Socket_Handle, $dgram, 0, $paddr);
recv(Socket_Handle, $dgram, 1024, 0);
print "Server Responded with:\n$dgram\n\n";

exit;

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-04-08 06:18
    Worked for me!

    udptest.gif
    669 x 338 - 7K
  • Mike GMike G Posts: 2,702
    edited 2011-04-08 06:50
    Beau, I dropped a UDP test page at http://www.agaverobotics.com/spinneret/udptest.aspx. It defaults to your IP and port but I can remove the defaults if you like.
  • Beau SchwabeBeau Schwabe Posts: 6,557
    edited 2011-04-08 07:09
    Mike G,

    Thanks!

    Don't worry about changing the defaults, those are fine (until I reboot the cable modem)

    I did change the 'time' it was way off by 5 hours, and I updated something on this end that should make the pings much faster.

    Thanks again ... I'll just let this run for awhile (days) and make sure it doesn't get hung up anywhere.
  • mindrobotsmindrobots Posts: 6,506
    edited 2011-04-08 19:05
    Beau,

    Pinging from Perl tonight and it's working fine. I'll try pinging from my Spinners tomorrow.

    Thanks for the code!

    Rick
  • LtechLtech Posts: 370
    edited 2011-09-07 13:22
    I have a trouble on port length:
    When my port number has 4 digit it is working fine, but I need 6 digit port 56629
    The terminal prompt "Socket NOT Connected" direct after power on
    I gees it is in building of the buffer
    On "ServerPORT / 256" and "ServerPORT & $FF" I do not understand the function?

    Thanks



    '                              Build UDP Packet
    '≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈
           i := StrSize(@MessageSentToServer)
           BYTEMOVE(@Buffer,@RemoteIPaddr,4)                'data[0]..[3] is the destination IP address
           byte[@Buffer][4] := ServerPORT / 256
           byte[@Buffer][5] := ServerPORT & $FF             'data[4],[5] is the destination port
           byte[@Buffer][6] := i / 256                         
           byte[@Buffer][7] := i & $FF                      'data[6],[7] is the payload size
           bytemove(@Buffer+8,@MessageSentToServer,i)
                                                            'data[8] starts the payload
    
    
  • Mike GMike G Posts: 2,702
    edited 2011-09-07 13:30
    Ltech, the math just splits 56629 into two bytes.

    56629 is 0xDD35h

    0xDD35h / 256 = 0xDDh
    0xDD35h & 0xFF = 0x35h
Sign In or Register to comment.