I have set up a server in Processing that receives HTTP posts.
http://www.jackkalish.com
But, it seems that I need to post a response to the client in order for it not to time out. (200 OK)
The client is in Ruby, and the Server is in processing.
I also tried to call: speakingClient.write("200 OK");
I am using the Server and Client classes in processing. See the code below:
- /*
- Test Server Program
- Language: Processing
- Creates a server that listens for cliencts and prints what they say.
- It also sends the last client anything that's typed on the keyboard.
- */
- // Include the net library
- import processing.net.*;
- int port = 3000; // the port the server listens on
- Server myServer; // the server object
- Client thisClient; // incoming client object
- void setup()
- {
- myServer = new Server(this, port); // Start the server
- }
- void draw()
- {
- // get the next client that sends a message:
- Client speakingClient = myServer.available();
- // if the message is not null, display what it sent:
- if (speakingClient != null) {
- String whatClientSaid = speakingClient.readString();
- // print who sent the message, and what they sent:
- println(speakingClient.ip()+"\t"+whatClientSaid);
- }
- }
- // ServerEvent message is generated when a new client connects to the server.
- void serverEvent(Server myServer, Client someClient) {
- println("We have a new client: " + someClient.ip());
- thisClient = someClient;
- }
- void keyReleased() {
- // only send if there's a vlient to send to:
- if (thisClient != null) {
- // if return is pressed, send newline and carriage feed:
- if (key == '\n') {
- thisClient.write("\r\n");
- }
- // send any other key as is:
- else {
- thisClient.write(key);
- }
- }
- }
http://www.jackkalish.com
1