Socket - web server problems

I have a webserver developed from scratch in Microsoft visual c ++ 2019. I use only c/c++, when I receive the request, I process it and build a response that I send to the client. I use my iPhone (13 pro with iOS 15.2).

Case 1: I am connected to a local wi-fi, I type the server address (local address or external address by port forwarding), it receives 'get / http ...' and 'get / other resources' through 3-4 simultaneous connections and responds with the content of the requested page. The connections remain stable and I can navigate further through the site, opening other pages without any problems. iPhone send requests and my server respond. everything works fine.

Case 2: I am connected only to the telephone operator (4G Vodafone), I type the external server address, it receives 'get / http ...' and 'get / other resources' through 3-4 simultaneous connections and responds with the content of the requested page. (just once, only first page). After that, the connections disappear and I can no longer browse the site (because I lose the session ID and other credentials). **In fact, the iPhone, after receiving what it requested, sends many null buffers and my server disconnects all sockets immediately. is something to do with WSAENOBUF, but I don't know what.   **

Why this dual behavior. How can I solve this situation?

Thank you very much.

Replies

That is a question for the guys a Microsoft.

  • No, of course not. Microsoft has nothing to do with data packets sent by iPhone and Safari.

Add a Comment

No, of course not. Microsoft has nothing to do with data packets sent by iPhone and Safari.

Add a Comment
  1. Who wrote the webserver?
  2. What compiler tools did you use to write the webserver?
  3. Who is sending the packets to the clients?
  4. Is your handcrafted webserver following all of the RFC-based specs?
  5. Was the webserver written with Xcode, does it run on the mac or any Apple mobile products?

In this scenario, your web server is sending data in response to a client, not the other way around other than a get URL request.

I wrote the code for the web server. I try to implement an IOCP server. I wrote it in Visual C++ 2019, using the standard settings (ISO C++ 14).

The server is listening. When it receives a request from a web client, builds a package based on that request and sends it to the client. e.g. the client sends the request 'GET /index.htm bla, bla, ...', the server identifies the received command, searches for file 'index.htm', adds the necessary headers like (HTTP/1.1 200 OK, Server Name, bla, bla, ... ) and sends it back to the client. and so on... (something like CGI). everything works fine (as I want it to work) on a wi-fi/local network (intranet network). I open safari on my iPhone 13, type in a local address and enter. the server receives multiple connections, one for get index.htm, another for I don't know what picture, another for I don't know what css, etc, etc. For each request, the server looks for the respective file, puts its headers and sends the answer to the client. In this case the iPhone don't send null buffers and I keep the connection until idle or close the browser. It is ok.

But when I'm on 4G for example, I type the address. In the same way several connections are created, each one asks for something and receives ok. At the end of the reception (all things received, index.htm, img, css, etc, etc), iPhone sends to the server a lot of null buffers and load the socket with null packets. In this case I have to disconnect those sockets. In which case I lose IDs and other credentials

In conclusion, the same iPhone and Safari, when communicating with my server over the local network (same class of IPs), send only the requests found in the html files, without null buffers (it is ok), but when I'm connected to the internet (different IP classes), it sends requests from html files, but in the end it doesn't stop sending null buffers (I print each packet received by the server. the same is seen in WireShark). (it is not ok because I have to disconnect it).

When I use other devices other than Apple (like Android, Windows), everything goes very well, both on the intranet and on the internet.

I tried to take into account the requirements of the RFC, as much as I could and as much as I understood.

I will find a compromise solution in the end, but I do not understand why this happens.

Best Regards, Catalin

  • Hi, can't anyone help me? You are all very good, and this is trivial or whatever ?

Add a Comment