user1692342
user1692342

Reputation: 5237

How is port redirecting done in C in Windows?

I have a project in C , in which I receive HTTP GET Requests (port 10000), process it and send appropriate response. I use winsock Libraries for network connections. Also I have a module which receives HTTPS request on a different port (port 10001). The client specifies which port it has to send to , if it is sending a http message it will send on port 10000 and if it is a https request it will send to port 10001. Due to this I realize, that the coming request is a HTTP or HTTPS request. There is a requirement, that the client will specify only one port number whether it is HTTP or HTTPS, i.e. it will send only on port 10000.

So now, when an HTTPS message comes on port 10000, it will be all encrypted but I want that message to go to port 10001. Is there any way to differentiate a HTTP or HTTPS request at the server level ?

Upvotes: 0

Views: 86

Answers (1)

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

If the first byte coming from client is 0x16, it's the beginning of SSL handshake. As it's not a possible start of HTTP request, you can differentiate requests by this property.

Upvotes: 2

Related Questions