Code Monkey home page Code Monkey logo

Comments (10)

mhanuel26 avatar mhanuel26 commented on July 19, 2024

Hello sandeepmistry,

I have tested and I think either there is an issue with available() method of server or I am not getting it, when you call available method from server and a new connection arrives, the method returns the following
return WiFiClient(((flag & SOCKET_BUFFER_FLAG_SPAWN_SOCKET_MSK) >> SOCKET_BUFFER_FLAG_SPAWN_SOCKET_POS), _socket + 1);

on WiFiServer.cpp

then, I have debugged the issue, since the second connection is getting the right socket number, but reference is lost in _client array of WiFiServer class, in WiFiClient constructor a new WiFi client is added to WiFi array of pointer by doing

WiFi._client[_socket] = this;

on WiFiClient::WiFiClient(uint8_t sock, uint8_t parentsock) method from WiFiClient.cpp

But then no memory is reserve so when available returns there pointer just get lost.

I understand the _client array of pointers should be used for holding client instances of connections but it seems there is some lack for this management in library.

I try to call available with new WiFiClient(server.available()), but same situation.

I finally get it working by returning new WiFiClass in available function of server,that is

return new WiFiClient(((flag & SOCKET_BUFFER_FLAG_SPAWN_SOCKET_MSK) >> SOCKET_BUFFER_FLAG_SPAWN_SOCKET_POS), _socket + 1);

This way you need to delete memory in you code, don't know if necessary but I am also doing

if (WiFi._client[_socket] == this){
    M2M_INFO("remove socket %d from WiFi _client pointer list", _socket);
    WiFi._client[_socket] = 0;
}

since you assign but then when you delete memory, there is a undefined reference in client array of server.

Please let me know your thoughts,

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mhanuel26,

I've submitted #77 to try to resolve this. If you get a chance please try it, you can download it from the following link and replace <sketch book>/libraries/WiFi101 with it.

https://github.com/sandeepmistry/WiFi101/archive/socket-buffer.zip

from wifi101.

mhanuel26 avatar mhanuel26 commented on July 19, 2024

Hi sandeepmistry,

I will try to integrate your changes asap and test if there are no more issues. Will let you know if there is a problem. By the way I open I ticket at Atmel because of #70 but never got response from them, perhaps the Microchip switch has take over... but I am seeing you did some changes to socket low level library too that might fix it.

Thank you

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mhanuel26,

Thank you for trying out the changes.

Could you please share your ticket number for #70 in a comment in that issue. I can open another support ticket to follow up on it.

from wifi101.

mhanuel26 avatar mhanuel26 commented on July 19, 2024

Hi sandeepmistry,

Yes I will test everything, just please wait for my feedback, I need to carefully replace your changes since I already did some changes as a workaround here. My workaround was working but I have an issue when serving a jQuery web page with other files like .css, it seems the browser open several sockets or do something that freeze the board even if I have been careful to allow access to SD card. Will try to confirm with your changes where is the problem and let you know, just give me sometime.

Thank you,

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mhanuel26, have you had a chance to test out the changes yet?

from wifi101.

mhanuel26 avatar mhanuel26 commented on July 19, 2024

Hi sandeepmistry,

Haven't been busy with other stuff last two weeks, I will do my best to test it asap.

Sorry for the delay.

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

Hi @mhanuel26, any updates on this?

from wifi101.

sandeepmistry avatar sandeepmistry commented on July 19, 2024

I'm going to close this for now, I think it's a duplicate of #36.

Whenever you get a chance, please try out PR #77 and provide your feedback.

from wifi101.

KrisKasprzak avatar KrisKasprzak commented on July 19, 2024

Has anyone got multiple clients to connect? if so how?

i have a WINC1500 wifi module connected to my Teensy 3.2 and using the libraries at https://github.com/arduino-libraries/WiFi101, and I tried this lib https://github.com/sandeepmistry/WiFi101/archive/socket-buffer.zip

After adding the line in setup(), WiFi.setPins(8, 7, 4, 2); code runs and I can connect my Android phone to this web server and point my phones Chrome browser to 196.168.1.1 and the web page generated by the server displays correctly.

However I'm trying to connect a second phone to the web server, and the phone fails to make the connection.

Anyone get this to work?

from wifi101.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.