aboutsummaryrefslogtreecommitdiff
path: root/libraries/Ethernet/EthernetServer.cpp
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2013-08-23 15:59:24 +0200
committerCristian Maglie <c.maglie@bug.st>2013-08-23 15:59:24 +0200
commit540743129b2badb813b703208d121ff14553c147 (patch)
tree6fadb4ebce68e1f0cb298a282be135c23fd156ed /libraries/Ethernet/EthernetServer.cpp
parent073b3ac9d4ae93ac0bb3a91afc65ae9d8f1d5d59 (diff)
parent67c84855c2f3ce99b091a756bb2ca1a016260659 (diff)
Merge branch 'ide-1.5.x' into dev-ide-1.5.x-discovery
Conflicts: app/src/processing/app/Preferences.java app/src/processing/app/debug/Uploader.java
Diffstat (limited to 'libraries/Ethernet/EthernetServer.cpp')
-rw-r--r--libraries/Ethernet/EthernetServer.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/libraries/Ethernet/EthernetServer.cpp b/libraries/Ethernet/EthernetServer.cpp
deleted file mode 100644
index 0308b92..0000000
--- a/libraries/Ethernet/EthernetServer.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "w5100.h"
-#include "socket.h"
-extern "C" {
-#include "string.h"
-}
-
-#include "Ethernet.h"
-#include "EthernetClient.h"
-#include "EthernetServer.h"
-
-EthernetServer::EthernetServer(uint16_t port)
-{
- _port = port;
-}
-
-void EthernetServer::begin()
-{
- for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
- EthernetClient client(sock);
- if (client.status() == SnSR::CLOSED) {
- socket(sock, SnMR::TCP, _port, 0);
- listen(sock);
- EthernetClass::_server_port[sock] = _port;
- break;
- }
- }
-}
-
-void EthernetServer::accept()
-{
- int listening = 0;
-
- for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
- EthernetClient client(sock);
-
- if (EthernetClass::_server_port[sock] == _port) {
- if (client.status() == SnSR::LISTEN) {
- listening = 1;
- }
- else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) {
- client.stop();
- }
- }
- }
-
- if (!listening) {
- begin();
- }
-}
-
-EthernetClient EthernetServer::available()
-{
- accept();
-
- for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
- EthernetClient client(sock);
- if (EthernetClass::_server_port[sock] == _port &&
- (client.status() == SnSR::ESTABLISHED ||
- client.status() == SnSR::CLOSE_WAIT)) {
- if (client.available()) {
- // XXX: don't always pick the lowest numbered socket.
- return client;
- }
- }
- }
-
- return EthernetClient(MAX_SOCK_NUM);
-}
-
-size_t EthernetServer::write(uint8_t b)
-{
- return write(&b, 1);
-}
-
-size_t EthernetServer::write(const uint8_t *buffer, size_t size)
-{
- size_t n = 0;
-
- accept();
-
- for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
- EthernetClient client(sock);
-
- if (EthernetClass::_server_port[sock] == _port &&
- client.status() == SnSR::ESTABLISHED) {
- n += client.write(buffer, size);
- }
- }
-
- return n;
-}