Netlinx as Server?
vining
Posts: 4,368
I'm setting up multiple servers on my Netlix master to accept conntections from customers for their daily check in and various notifications and getting rid of the email notification for reasons discussed elsewhere. I'm basically done with the approach I took and I'm now thinking I took the wrong approach even though it works.
Currently my master has 6 DPS for use as servers each on 1 of 6 ports. If a customer's master attempts a connection and the server port is in use it rolls to the next port in the array, etc and this works fine but last night before bed I thought I should just create, again 6 DPS for 6 servers on my master but all to use the same port. On start up call one server to listen on the one port say 1080. If a client connects I open a second server on poet 1080 to listen while the first server is busy and when the first server finishes I shut it down and leave the second server open. Always maintaining 1 server for listening even if other server have connections. At first I was thinking this would work and would be the logical way of doing this but the more I think of it the more I'm not sure if this would even work using the same ports on different DPS's. Does anyone know if this approach would work or not? I really don't want to waste time if it can't possibly work especially when my original method does work. The only draw back I see with my original method is I have to maitain 6 servers listening all the time which really seems a waste.
Any insight would be appreciated.
Currently my master has 6 DPS for use as servers each on 1 of 6 ports. If a customer's master attempts a connection and the server port is in use it rolls to the next port in the array, etc and this works fine but last night before bed I thought I should just create, again 6 DPS for 6 servers on my master but all to use the same port. On start up call one server to listen on the one port say 1080. If a client connects I open a second server on poet 1080 to listen while the first server is busy and when the first server finishes I shut it down and leave the second server open. Always maintaining 1 server for listening even if other server have connections. At first I was thinking this would work and would be the logical way of doing this but the more I think of it the more I'm not sure if this would even work using the same ports on different DPS's. Does anyone know if this approach would work or not? I really don't want to waste time if it can't possibly work especially when my original method does work. The only draw back I see with my original method is I have to maitain 6 servers listening all the time which really seems a waste.
Any insight would be appreciated.
0
Comments
This may not help as it is still more complex, but I've seen TCP architectures for this purpose where one port is always listening for incoming connections, and the first thing once one arrives, the server assigns a new unique port and informs the incoming client where to go to continue, then drops and starts listening again for a new incoming contact. The starting port is never busy for long, and outside clients retry until serviced, informed, and moved to a new port just for their session.
Thanks for the insight and the idea.
Paul
Now what you're suggesting above, is that multiple servers using the same port? I had reservations about that being able to work and JN re-inforced that reservation. If it could then I could simply open 1 server for listening and start up another on the same port as clients connect but what JN said makes sense.
Either way having the clients kick to a different port to send traffic after autheticating is pretty simple and basically the opposite of what I have now which works but being anal has its pittfalls and sometimes just working isn't good enough.
Wouldn't it be faster to just try it?
Running this gives you two servers on port 2001. If you telnet to that port, you'll see "S1 online", and all the data from that telnet session will go to S1 (as seen in Diagnostics). Opening a second telnet session to the same port shows "S2 online", and all the data will go to S2. Both sessions are still active and talking to their respective ports. You can open and close up to two sessions with no problems. Increasing the number of DPS and IP_SERVER_OPEN calls increases the number of simultaneous sessions that can be open.
TCP requires each incoming connection to have a unique tuple (remoteIP, remotePort, localPort). You can have two connections to port 2001 on your processor because each one has a different remote port. For instance, from my laptop at 192.168.1.198 to the processor at .195, here's my netstat output with two connections open:
The two connections are from the same IP, but one is from source port 52618, the other is from 52712 -- this is how the two connections are kept differentiated. This would be a sad world if TCP could only handle one connection per server port per IP. Source ports are almost always randomly generated when you create a TCP connection (for instance, IP_CLIENT_OPEN doesn't let you pick your source port).
If you wanted, you could use a global variable to keep track of the number of connections, open one more server than you want there to be possible connections, and if the maximum number of connections has been reached, have the server tell the client "maximum connections reached" and hang up right away.
I use a DEV array for all my sockets, they are all treated the same (because you don't know what order they will pick up incoming connections in). GET_LAST can be used if you need to keep track of state for a connection.
Thanks guys! Wish I gave this more thought before making my backwards appraoch module.
What kind of overhead does an idle server place on the system anyway? I wouldn't suppose much but WTF do I know.
It's not? No Easter Bunny either?
Thanks for clearing up these IP concepts.
By trying to simplify it you are making it more complicated it seems. Creating 6 sockets isn't going to hurt anything especially if they are idle most of the time. But why do you need 6 sockets if the traffic is so rare? One socket would most likely do unless you have so much traffic that connections are getting missed due to the few moments the socket is unavailable after closing but before opening. If you look at the Kaleidescape module, all traffic is through one port and serves 32 players and 32 touch panels I believe.
Paul
All my clients will be sending their daily sitrep at midnight so I want to have enough servers available so they don't have to keep trying until the server is free since masters tend to hand a bit while IP connections are pending or timing out. Also by creating a module for 6 servers I can easily scale it either way, up or down and right now since some of my daily logs are over 40 kbytes I'm just trying to create an architecture that has flexability so I don't have to do this a 3rd time and since I don't really know what I'm doing I figure I'd over design it. Besides I don't get paid for writing code so there's no one to yell at me for wasting time.