No server?

BlitzPlus Forums/BlitzPlus Programming/No server?

Ked(Posted 2007) [#1]
I am about to start an application called LAN Messenger and I am wondering if it's possible to send messages to and from computers without creating a server? If I went with the server then the people would have to find out what IP to connect to everyday, if the network is set up to have dynamic IP addresses. It just seems easier to do it without a server. Is this possible?

Thanks.


xlsior(Posted 2007) [#2]
Probably, except without a server things get even messier because you don't know the address of *any* of the users. The whole point of a server is that it keeps track of that info in a single place, so any user can just ask the server where to find any other user.


William Drescher(Posted 2007) [#3]
I agree with xlsior, servers are what make the World Wide Web go round...


Ked(Posted 2007) [#4]
Well... is there any way to find out what IP is hosting the server on a specified port?


ford escort(Posted 2007) [#5]
IMHO a serverless a^roach is still possible with using a kind of port scanner, but might be slow, a standard ip set rules for local network just change the last number for every client connected, so just looking at all possible adresses on the correct port might do the trick and store the result in an aray for future uses

something like that
dim clients(255) ; to store the active client list

ip$="192.168.0."
for a=1 to 255 ; might change on available ip ranse
 clients(a)=opentcpstream(ip$+str$(a),port)
next

if there's no client the client(x) will be set to 0 else you'll have the stream handle to send/receive from this client


xlsior(Posted 2007) [#6]
Technically you can send a broadcast message to the LAN, and any PC in the subnet will receive it. If the server is among these, it can then respond appropriately.

Unfortunately, there's a snag: While most LAN's use subnets of 256 IP's, that's not always the case. If your own IP is 192.168.1.17, then *most* of the time the broadcast IP that all workstations in the 192.168.1.x range will receive is 192.168.1.255... But that's not set in stone, and many networks use smaller subnets, and some use larger ones.

The broadcast address is the last IP in the subnet -- but to find the size of your subnet and thereby accurately determine the broadcast address, you need the netmask (typically 255.255.255.0)

Unfortunately blitzmax does not come with any built-in commands to obtain your netmask. Without the netmask, you cannot accurately determine your broadcast address.

Of course, port scanning is an option as well, but probably should be used with caution since many networks have a terms of service that prohibit doing that, especially if you're on public IP space and only have a small subnet allocated to you.


Ked(Posted 2007) [#7]
What about a client that wants to connect to the server but doesn't know the server's IP address. How would I find the server's IP?


xlsior(Posted 2007) [#8]
What about a client that wants to connect to the server but doesn't know the server's IP address. How would I find the server's IP?


Ideally a server would have a static name/address.

Pretty much any 'real' server would.
You can get a cheap workaround by using DynDNS.org, although that would point to the external routable IP of a machine, not a LAN IP.

If you don't know the address of the server but do know that it (should) exist(s) on your own network segment, you can send a request to the broadcast address of your local LAN and set up the server to listen to those and respond to appropriate messages.

Unfortunately, you still have the same limitation here that you really ought to know the netmask first to reliably find out the broadcast address.

...*anyone* have any pointers on how to obtain that info from BlitzMax?


Ked(Posted 2007) [#9]
There's a code in the code archives that gives you the broadcast address. But how would I send messages to it?

http://www.blitzbasic.com/codearcs/codearcs.php?code=1988


xlsior(Posted 2007) [#10]
But how would I send messages to it?


Exactly the same as sending messages to any other IP -- the difference is that any message send to the broadcast IP will be received by *all* computers on the network, including your server.

you'd need to come up with some kind of 'handshake', where if the server receives the broadcast message it will open a connection to a specific port on the sending PC where it can communicate some of the settings such as the server's actual IP address.

Keep in mind that any info sent to the broadcast IP is by design visible to any computer on the network, so don't send any confidential info such as username/password stuff there. Just use it for a handshake so the server and client can then make a direct connection, and send login info over *that* connection instead.

By the way: thanks for the link to that code archives bit to get the broadcast IP. Too bad it requires an external DLL. :-?


Ked(Posted 2007) [#11]
Exactly the same as sending messages to any other IP

I'm not sure I'm understanding. Can I send messages to it using Blitz? What is the port number?

By the way: thanks for the link to that code archives bit to get the broadcast IP.

No problem. ;]


xlsior(Posted 2007) [#12]
the port number would be whatever port you have a blitz program listen to. You can pick one -- pretty much anything above 1024 is fair game.

but you would need either a dedicated server listen to that port, or if you go serverless each client needs to listen to that port and essentially run a stripped-down server itself.


Wings(Posted 2007) [#13]
if you gona make a messanger.
you must at least have a list of servers.

messages sent will not have to go via server. server just hols the user IP and Username logins.

the rest UDP or TCP can handle. P2P.


Ked(Posted 2007) [#14]
How would I do something P2P-style?

if you gona make a messanger.
you must at least have a list of servers.

Its gonna be an LAN Messenger