For a CTIN544 assignment, this program demonstrates use of the networking library built into Processing.
UPDATED: Fixed a bug in the server and extensively commented the code. No longer including compiled builds, but leave a comment if you need one. You can compile it yourself on any system using Processing.
Start the server. A red dot will follow your mouse if you move it over the window. Start the client, on the same machine or another one on the same LAN. When prompted by the client, type in the IP address of the server computer (or "localhost" if it's the same machine). Now there will be two dots in both windows, synchronized. One follows the mouse in the server window, and the other follows the mouse in the client window.
You can connect multiple clients to the same server, but the behavior isn't exactly what you might expect. The server's red dot will appear in all client windows, and all client dots will appear in the server's window, but clients won't be able to see their peers. I ran out of time trying to implement that functionality, but Processing is certainly capable of it.
Overall, using the Network library isn't hard, but it does require that you think about how you're going to structure communication between the server and clients, and decide what functionality should go where. Unfortunately, I didn't find a really good tutorial for working with networking, but the library functions themselves are pretty well documented and there are a couple simple examples on the Processing.org page.
Comments (1)
I'm very interested in your works. Because one of my works needs network data transfer.
By referensing your source code, I implement network module. It's very well and a lot of comment help me. Thank you!!
By the way, I trid to comunicate over TCP/IP(this mean not to use 127.0.0.1).
I read TCP buffer every frame(24fps),
sometimes app receive nothing, but few times later, it receive multipule data.
It seems server send data, but low level TCP cannot receive at that timing.
frameRate = 15, missing, missing, data(recently 3data) missing, missing, data(recently 3data).....repeat...
frameRate = 5, almost good ^^;
(my data is bigger than yours..... it affect me..)
Your code looks like using only first data of receive buffer. Under some situation, somedata is remein on the buffer. It'll be overflow. If you have the same trouble, you check aroud there.
Posted by hide
|
February 3, 2009 11:11 AM
Posted on February 3, 2009 11:11