[Implemented] Network serveur listening on local IP only ...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Niffo
Enthusiast
Enthusiast
Posts: 504
Joined: Tue Jan 31, 2006 9:43 am
Location: France

[Implemented] Network serveur listening on local IP only ...

Post by Niffo »

When initialising a network server (CreateNetworkServer()), it would be a great thing to be able to specify the IP address to listen like we can do with WinSocks

Code: Select all

sin\sin_addr = inet_addr_("127.0.0.1")
sin\sin_addr = #INADDR_ANY
One of the advantages is that the Windows Firewall does not triggers when listening on local IP.
Last edited by Niffo on Wed May 05, 2010 9:07 am, edited 1 time in total.
Niffo
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Something similar has been requested some months before.

It would be nice to define the IP numbers for the created network server. It would also be nice to accept the connection from within our code and not automaticaly as it is done now.

There are many improvements required on the network lib to use it for commercial applications. (for example: an option for disable the receive of files on a server socket)
Tranquil
infratec
Always Here
Always Here
Posts: 7577
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Network serveur listening on local IP only ...

Post by infratec »

Hi,

since I wrote yesterday a small server program and it was not working as expected,
I fully argree with you.

I had forgotten, that I have a second network card in my PC.
And, shit happens, my program used this IP number to connect the server to it.

Result: half an hour of searching a fault, why the client does not connect to the server. :cry:

Best regards,

Bernd
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Re:

Post by helpy »

Tranquil wrote:There are many improvements required on the network lib to use it for commercial applications. (for example: an option for disable the receive of files on a server socket)
It is possible to use ReceiveNetworkData() (instead of ReceiveNetworkFile()) to receive files, which are sent with SendNetworkFile().

SendNetworkFile() sends a file like this:

Code: Select all

First 8 Bytes:      PBMGSFLE
Than a long:        [Size of File]
Than the file data: [Bytes]
If the client is not allowed to send files to the server, the server could close the connection to the client. As soon as you get an #PB_NetworkEvent_FIle you can CloseNetworkConnection(EventClient()), because the client does not keep the "server rules".

What are you doing if a "bad client" is sending a lot of chunk data?

cu,
helpy
Windows 10 / Windows 7
PB Last Final / Last Beta Testing
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Re: Network serveur listening on local IP only ...

Post by Tranquil »

Thats a good hint! Atm I just use ReceiveNetworkData() which gets first some information on the datas that will received (size of package etc) and after that a validation has been done. If validation is false the connection will be closed.
Tranquil
Post Reply