Skip to content

Commit ab2fc7b

Browse files
committed
Rename fnTcpServer::available() to fnTcpServer::client()
The available() method should return the number of bytes available to be read to be consistent with the rest of FujiNet. It returns fnTcpClient so it makes more sense to call it client().
1 parent ad2e6c4 commit ab2fc7b

File tree

7 files changed

+22
-22
lines changed

7 files changed

+22
-22
lines changed

lib/device/adamnet/keyboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ void adamKeyboard::adamnet_control_receive()
3535
{
3636
AdamNet.wait_for_idle();
3737
adamnet_send(0xC1); // NAK
38-
client = server->available();
38+
client = server->client();
3939
}
4040
else if (!client.connected())
4141
{
@@ -99,4 +99,4 @@ void adamKeyboard::adamnet_process(uint8_t b)
9999
void adamKeyboard::shutdown()
100100
{
101101
}
102-
#endif /* BUILD_ADAM */
102+
#endif /* BUILD_ADAM */

lib/device/adamnet/modem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ void adamModem::at_handle_answer()
481481
Debug_printf("HANDLE ANSWER !!!\n");
482482
if (tcpServer.hasClient())
483483
{
484-
tcpClient = tcpServer.available();
484+
tcpClient = tcpServer.client();
485485
tcpClient.setNoDelay(true); // try to disable naggle
486486
// tcpServer.stop();
487487
answerTimer = fnSystem.millis();
@@ -1269,4 +1269,4 @@ void adamModem::adamnet_process(uint8_t b)
12691269

12701270
}
12711271

1272-
#endif /* BUILD_ADAM */
1272+
#endif /* BUILD_ADAM */

lib/device/iwm/modem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ void iwmModem::at_handle_answer()
565565
Debug_printf("HANDLE ANSWER !!!\n");
566566
if (tcpServer.hasClient())
567567
{
568-
tcpClient = tcpServer.available();
568+
tcpClient = tcpServer.client();
569569
tcpClient.setNoDelay(true); // try to disable naggle
570570
// tcpServer.stop();
571571
answerTimer = fnSystem.millis();

lib/device/sio/modem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ void modem::at_handle_answer()
10581058
Debug_printf("HANDLE ANSWER !!!\n");
10591059
if (tcpServer.hasClient())
10601060
{
1061-
tcpClient = tcpServer.available();
1061+
tcpClient = tcpServer.client();
10621062
tcpClient.setNoDelay(true); // try to disable naggle
10631063
// tcpServer.stop();
10641064
answerTimer = fnSystem.millis();

lib/network-protocol/TCP.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ bool NetworkProtocolTCP::special_accept_connection()
362362
unsigned char remotePort;
363363
char *remoteIPString;
364364

365-
client = server->available();
365+
client = server->client();
366366

367367
if (client.connected())
368368
{
@@ -422,4 +422,4 @@ bool NetworkProtocolTCP::special_close_client_connection()
422422
client.stop();
423423

424424
return false;
425-
}
425+
}

lib/tcpip/fnTcpServer.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,6 @@ int fnTcpServer::begin(uint16_t port)
3131
return 0;
3232
}
3333

34-
// Bind socket to our interface
35-
struct sockaddr_in server;
36-
server.sin_family = AF_INET;
37-
server.sin_addr.s_addr = INADDR_ANY;
38-
server.sin_port = htons(_port);
39-
if (bind(_sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
40-
{
41-
Debug_printf("fnTcpServer::begin failed to bind socket, err %d\r\n", compat_getsockerr());
42-
return 0;
43-
}
44-
4534
int enable = 1;
4635
#if defined(_WIN32)
4736
if (setsockopt(_sockfd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, (char *) &enable, sizeof(enable)) != 0)
@@ -59,6 +48,17 @@ int fnTcpServer::begin(uint16_t port)
5948

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

51+
// Bind socket to our interface
52+
struct sockaddr_in server;
53+
server.sin_family = AF_INET;
54+
server.sin_addr.s_addr = INADDR_ANY;
55+
server.sin_port = htons(_port);
56+
if (bind(_sockfd, (struct sockaddr *)&server, sizeof(server)) < 0)
57+
{
58+
Debug_printf("fnTcpServer::begin failed to bind socket, err %d\r\n", compat_getsockerr());
59+
return 0;
60+
}
61+
6262
// Now listen in on this socket
6363
if (listen(_sockfd, _max_clients) < 0)
6464
{
@@ -107,7 +107,7 @@ bool fnTcpServer::hasClient()
107107

108108
// Returns a new fnTcpClient initialized with the client currently connected to the socket
109109
// or disconnected (uninitialized) fnTcpClient
110-
fnTcpClient fnTcpServer::available()
110+
fnTcpClient fnTcpServer::client()
111111
{
112112
// Return initialized fnTcpClient if we're not in listening mode
113113
if (!_listening)

lib/tcpip/fnTcpServer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ class fnTcpServer
2323

2424
int begin(uint16_t port=0);
2525

26-
fnTcpClient accept(){ return available(); }
26+
fnTcpClient accept(){ return client(); }
2727
void setNoDelay(bool nodelay) { _noDelay = nodelay; };
2828
bool getNoDelay() {return _noDelay; };
2929
int setTimeout(uint32_t seconds);
3030
void setMaxClients(int maxClients) { _max_clients = maxClients; }
3131

3232
bool hasClient();
33-
fnTcpClient available();
33+
fnTcpClient client();
3434

3535
void stop();
3636

0 commit comments

Comments
 (0)