Author Topic: More HTTP sessions on a different port?  (Read 13902 times)

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
More HTTP sessions on a different port?
« on: November 22, 2009, 11:29:29 AM »
I've already done this and it works but it's pretty ugly and implemented in a bad way....

So now i'm going to see if it's already been done, asked for or on your to do list Mark.

I wanted to have a way to use http locally using port 80 and be able to access the same pages remotely. I could port forward port 80 at the router(that has world facing ip address) to port 80 at my uTasker device but i wanted to keep it free for something else.

Plus, if two of this utasker project were used on the same network, i can't port forward port 80 to two different devices wth two IPs.

So i decided i wanted to add 4 more http sessions that would listen for connections on another port number that was world facing using port fowarding at the router on the port number i had chosen. I am still keeping the original 4 sessions that are listening for port 80 connections.

I'm not really worried out data on the pagesbeing out of sync. It will likely be only used by one person who is either on the local network or remote elsewhere so i dont expect feedback on the webpages being out of sync with reality because two people are manipulating the web pages at the same time.

All i did was replicate all? (most) of the functions in HTTP.c and given them a slightly different name. The sessions and message pointer is also replicated.

static HTTP         *ptrALT_HTTP = 0;
static TCP_MESSAGE              *ALT_HTTP_Tx = 0;

Anyway.............thoughts? It works so i'm satisfied with that. But i'm happy to hear about a method that would have been easier, less code space wasting and more elegant. Also happy to hear of any side effects i haven't seen or thought about yet.

JD

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3240
    • View Profile
    • uTasker
Re: More HTTP sessions on a different port?
« Reply #1 on: November 22, 2009, 02:36:55 PM »
Hi JD

Are you sure that this is not possible by configuring virtual servers at your router?
I am not sure whether you have a special requirement that I haven't understood correctly but there should be no problem having multiple internal devices listening on port 80.

Assuming: main web server at 192.168.0.11 and 2 embedded devices at 192.168.0.12. and 192.168.0.13 and external address 182.234.21.33.
By adding virtual servers to the router which translate, for example, TCP ports 8080 and 8081 to internal 192.168.0.12 port 80 and 192.168.0.13 port 80 respectively you can have your main web server effectively listening on the 182.234.21.33:80 and the embedded devices in 182.234.21.33:8080 and 182.234.21.33:8081 on the external IP address. Internally they still have their internal IP addresses, each on port 80.

Regards

Mark

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: More HTTP sessions on a different port?
« Reply #2 on: November 26, 2009, 06:16:45 AM »
Yeah. Of course you're right. Not sure what i was thinking.

Now i'm trying to think of another reason to use it just cos ive done it.
I guess you could use different web parameters, different web handler or even different web pages?

JD