Using same socket for second send + recv giving no result?

when I want to use the same socket connected to the host to send() and recv() for the second time, recv() will return 0 without anything in buffer

basically Im doing:

1. connect to the website
2. send packets
3. receive packets
4. send packets again (I think this one is working since it's not giving me SOCKET_ERROR)
5. receive packets again (this one is returning 0 so as "connection closed")

source code:

as you can see, I have sock2, which when I use for second send/recv it's working fine, however I will do more communication, and having sockets for all of that and connecting them would be kinda stupid I guess
Last edited on
External libraries save a lot of work for doing things that have been done before, such as connecting to a web site, although there is a learning curve in using external libraries. Doing it yourself is a good way to learn the underlying techniquies.

Since you want to connect to a web site, you're going to need to learn HTTP protocol.

You're going to need to build a HTTP post request and you're going to need to parse the HTTP response. This is where existing libraries will save you a lot of work.

there's new "error" in main post
Last edited on
someone? I now have issues with sockets instead of HTTP requests
Topic archived. No new replies allowed.