/*** TCP:4444portで受信したStringをprintlnする Stringをechoもする Compiler: Proce55ing 0097Beta Date: 2005/12/13 Author: Sho Hashimoto WebSite: http://web.sfc.keio.ac.jp/~t03792sh/ ***/ import processing.net.*; int port = 4444; Server server; String str; void setup(){ size(200,200); server = new Server(this, port); } void draw(){ Client client = server.available(); // 接続してきたClient if(client != null){ // Clientがいるなら if((str=client.readString()) != null){ // 文字列を送ってきているなら受信 print(str); // 受信した文字列 client.write("echo: "+str); // Clientに送り返す } } } /* Clientが接続した時 */ void serverEvent(Server s, Client c){ println("Client connect - IP:"+c.ip()); // IPアドレス表示 }