Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/device/adamnet/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void adamKeyboard::adamnet_control_receive()
{
AdamNet.wait_for_idle();
adamnet_send(0xC1); // NAK
client = server->available();
client = server->client();
}
else if (!client.connected())
{
Expand Down Expand Up @@ -99,4 +99,4 @@ void adamKeyboard::adamnet_process(uint8_t b)
void adamKeyboard::shutdown()
{
}
#endif /* BUILD_ADAM */
#endif /* BUILD_ADAM */
4 changes: 2 additions & 2 deletions lib/device/adamnet/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void adamModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down Expand Up @@ -1269,4 +1269,4 @@ void adamModem::adamnet_process(uint8_t b)

}

#endif /* BUILD_ADAM */
#endif /* BUILD_ADAM */
2 changes: 1 addition & 1 deletion lib/device/comlynx/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void lynxKeyboard::comlynx_control_receive()
{
ComLynx.wait_for_idle();
comlynx_send(0xC1); // NAK
client = server->available();
client = server->client();
}
else if (!client.connected())
{
Expand Down
2 changes: 1 addition & 1 deletion lib/device/comlynx/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void lynxModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/drivewire/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ void drivewireModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/h89/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ void H89Modem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/iwm/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void iwmModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/mac/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void iwmModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/new/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void adamKeyboard::adamnet_control_receive()
{
AdamNet.wait_for_idle();
adamnet_send(0xC1); // NAK
client = server->available();
client = server->client();
}
else if (!client.connected())
{
Expand Down
2 changes: 1 addition & 1 deletion lib/device/new/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void adamModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/new/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void adamSerial::adamnet_response_status()
if (!client.connected() && server->hasClient())
{
// Accept waiting connection
client = server->available();
client = server->client();
}

if (client.available())
Expand Down
2 changes: 1 addition & 1 deletion lib/device/rc2014/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ void rc2014Modem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/rs232/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ void rs232Modem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/s100spi/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void s100spiModem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
2 changes: 1 addition & 1 deletion lib/device/sio/modem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ void modem::at_handle_answer()
Debug_printf("HANDLE ANSWER !!!\n");
if (tcpServer.hasClient())
{
tcpClient = tcpServer.available();
tcpClient = tcpServer.client();
tcpClient.setNoDelay(true); // try to disable naggle
// tcpServer.stop();
answerTimer = fnSystem.millis();
Expand Down
4 changes: 2 additions & 2 deletions lib/network-protocol/TCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ bool NetworkProtocolTCP::special_accept_connection()
unsigned char remotePort;
char *remoteIPString;

client = server->available();
client = server->client();

if (client.connected())
{
Expand Down Expand Up @@ -422,4 +422,4 @@ bool NetworkProtocolTCP::special_close_client_connection()
client.stop();

return false;
}
}
24 changes: 12 additions & 12 deletions lib/tcpip/fnTcpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,6 @@ int fnTcpServer::begin(uint16_t port)
return 0;
}

// Bind socket to our interface
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(_port);
if (bind(_sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
{
Debug_printf("fnTcpServer::begin failed to bind socket, err %d\r\n", compat_getsockerr());
return 0;
}

int enable = 1;
#if defined(_WIN32)
if (setsockopt(_sockfd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &enable, sizeof(enable)) != 0)
Expand All @@ -59,6 +48,17 @@ int fnTcpServer::begin(uint16_t port)

Debug_printf("Max clients is currently %u\r\n",_max_clients);

// Bind socket to our interface
struct sockaddr_in server;
server.sin_family = AF_INET;
server.sin_addr.s_addr = INADDR_ANY;
server.sin_port = htons(_port);
if (bind(_sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
{
Debug_printf("fnTcpServer::begin failed to bind socket, err %d\r\n", compat_getsockerr());
return 0;
}

// Now listen in on this socket
if (listen(_sockfd, _max_clients) < 0)
{
Expand Down Expand Up @@ -107,7 +107,7 @@ bool fnTcpServer::hasClient()

// Returns a new fnTcpClient initialized with the client currently connected to the socket
// or disconnected (uninitialized) fnTcpClient
fnTcpClient fnTcpServer::available()
fnTcpClient fnTcpServer::client()
{
// Return initialized fnTcpClient if we're not in listening mode
if (!_listening)
Expand Down
4 changes: 2 additions & 2 deletions lib/tcpip/fnTcpServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ class fnTcpServer

int begin(uint16_t port=0);

fnTcpClient accept(){ return available(); }
fnTcpClient accept(){ return client(); }
void setNoDelay(bool nodelay) { _noDelay = nodelay; };
bool getNoDelay() {return _noDelay; };
int setTimeout(uint32_t seconds);
void setMaxClients(int maxClients) { _max_clients = maxClients; }

bool hasClient();
fnTcpClient available();
fnTcpClient client();

void stop();

Expand Down
Loading