mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-27 18:02:17 +03:00
emulation on host: fix nasty delay (#5840)
emulation with socket: fix nasty delay properly check all return values (read() returning 0 indicates closed peer) ClientContext::state() triggers read() to check for closed peer uart emulation on tty: add cmdline -b debug option to disable raw tty hide annoying MOCK messages, add cmdline -v option to show them uart emulation on tty: check more return values emulation on host: tcp/udp port shifting: new cmdline -s(port Shift) option
This commit is contained in:
@ -67,8 +67,18 @@ void WiFiServer::begin (uint16_t port)
|
||||
void WiFiServer::begin ()
|
||||
{
|
||||
int sock;
|
||||
int mockport;
|
||||
struct sockaddr_in server;
|
||||
|
||||
mockport = _port;
|
||||
if (mockport < 1024 && mock_port_shifter)
|
||||
{
|
||||
mockport += mock_port_shifter;
|
||||
fprintf(stderr, MOCK "=====> WiFiServer port: %d shifted to %d (use option -s) <=====\n", _port, mockport);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, MOCK "=====> WiFiServer port: %d <=====\n", mockport);
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
{
|
||||
perror(MOCK "socket()");
|
||||
@ -83,7 +93,7 @@ void WiFiServer::begin ()
|
||||
}
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_port = htons(_port);
|
||||
server.sin_port = htons(mockport);
|
||||
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
if (bind(sock, (struct sockaddr*)&server, sizeof(server)) == -1)
|
||||
{
|
||||
@ -118,6 +128,7 @@ size_t WiFiServer::write (uint8_t c)
|
||||
size_t WiFiServer::write (const uint8_t *buf, size_t size)
|
||||
{
|
||||
fprintf(stderr, MOCK "todo: WiFiServer::write(%p, %zd)\n", buf, size);
|
||||
exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user