WiFly module - Multiple connections?

Is is possible to have two devices open up separate ports on the Roving Network's WiFly module (rn-131). I've managed to open port 2000 and transmit data through but no other port seems to be available.

If the RN-131 is similar to the RN-171 (WiFly RN-XV) then it can only handle a single TCP connection at a time.

You could use UDP instead if you want to flexibly receive packets from multiple hosts.

Ah ok, that's frustrating. UDP looks like it could work well too though..have you had much experience with transfering over UDP? From looking at the WiFly manual briefly it looks as though no connection set-up is required..you just start sending messages?

dhunt:
If the RN-131 is similar to the RN-171 (WiFly RN-XV) then it can only handle a single TCP connection at a time.

Just to confirm, the user manual is common to them both, so they have that same limitation. From the title page:

User Manual and Command Reference
802.11 b/g Wireless LAN Modules
WIFLY GSX
RN-131G, RN-131C, RN-134,
RN-121, RN-123 & RN-125, RN-370
WIFLY EZX
RN-171, RN-174, RN-XV
Firmware Version 2.30
October 26th 2011
Copyright © 2011 Roving Networks, Inc. All Rights Reserved.

(emphasis added)

Cheers !

lukedom89:
Ah ok, that's frustrating. UDP looks like it could work well too though..have you had much experience with transfering over UDP? From looking at the WiFly manual briefly it looks as though no connection set-up is required..you just start sending messages?

Yeah, just set the host and remote port, and any data you write to the serial port will be sent as a UDP packet to that host and port. The default flush time is set to 10msecs, and the default max packet size is 64 bytes, so 10msecs after you send the last character of the message the UDP packet will be sent, or if you send 64 bytes then a packet will be sent.

You can also receive packets from any hosts, and if you set up UDP auto-pairing then you can get the ip address and port of the sender from the WiFly by reading the host and remote port. I'm not sure how well this works if you receive back-to-back packets. Auto-pairing is not compatible with sending since you have to set the host IP to 0.0.0.0 for it to work.

I should have mentioned that UDP is not a reliable protocol and packets may get dropped, so it you need to guarantee that messages are received then you'll have to add an ACK message, and resend if the ACK is not received. The WiFly has an auto-resend feature that might be useful for this where it will resend the message if it doesn't receive a response within a certain amount of time.